Integer to RGB components
How do I convert an integer value to r, g and b components?
E.g.
GetRed(16777215);
Would return 255. And similar functions for green and blue.
This is hiow I convert between long and rgb
Now I look at it, you can actully leave out the first bitand with 0xFF
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement