Sign in to follow this  
gaerg

Integer to RGB components

Recommended Posts

This is hiow I convert between long and rgb



CRgb( unsigned long Color )
{
this->rgbAlpha = static_cast<unsigned char>( (Color >> 24 ) & 0xFF );
this->rgbRed = static_cast<unsigned char>( (Color >> 16 ) & 0xFF );
this->rgbGreen = static_cast<unsigned char>( (Color >> 8 ) & 0xFF );
this->rgbBlue = static_cast<unsigned char>( Color & 0xFF );
}




Now I look at it, you can actully leave out the first bitand with 0xFF

Share this post


Link to post
Share on other sites

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