Sign in to follow this  

Shift/mask help

This topic is 3316 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, This is very rudimentary I suppose, but it's got my newbie brain all twisted up. If I have an unsigned int that represents colour (like so)... 0xAARRGGBB; /* Alpha, R, G, B */ ...how do I set the value of the alpha bytes, without disturbing the other bytes? (Using C on a big endian machine, if that makes a difference)

Share this post


Link to post
Share on other sites
Assuming the color value is 32 bits.

1) mask = 0x000000FF
2) masked = mask & color
3) alpha = masked << 24

Info on bit operations...
http://www.gamedev.net/reference/articles/article1563.asp

Share this post


Link to post
Share on other sites

This topic is 3316 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this