How can I convert a COLORREF varible to three integers (int r, g, b? I have been stumped about this for a very long time, thanks for any help, Queatrix.
How can I convert a COLORREF varible to three integers (int r, g, b? I have been stumped about this for a very long time, thanks for any help, Queatrix.
So just bitshifting and masking would be enoughWhen specifying an explicit RGB color, the COLORREF value has the following hexadecimal form:
0x00bbggrr
g = (cr >> 8) & 0xFF;
or as suggested in the MSDN
To create a COLORREF color value, use the RGB macro. To extract the individual values for the red, green, and blue components of a color value, use the GetRValue, GetGValue, and GetBValue macros, respectively.
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler