Jump to content
  • Advertisement
Sign in to follow this  
DrTwox

Shift/mask help

This topic is 3624 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!