Is there a way to convert a COLORREF value into the three RGB ints?
-B
Printable View
Is there a way to convert a COLORREF value into the three RGB ints?
-B
well I just figured it out so if anybody's interested in the answer:
COLORREF color;
int iRed = GetRValue(color);
int iBlue = GetBValue(color);
int iGreen = GetGValue(color);
Sometimes I amaze even myself. :lol: :lol: :lol: :D
may be you can stop amazing yourself by reading the documentation!!
:)
Yeah, but who has time for that. :ehh:
Reading the documentation?? That's cheating isn't it???
;) :rolleyes:
Quote:
Originally Posted by John E
I do believe it is. Isn't it an unwritten rule that programmers aren't supposed to read any documentation? ;) :D
Don't forget the following when looking at the different bytes of an integer:
https://www.safaribooksonline.com/li...080/re286.html
"RGB = red + (green * 256) + (blue * 65536)
In other words, the individual color components are stored in the opposite order than you would expect. VB stores the red color component in the low- order byte of the integer’s low-order word, the green color in the high-order byte of the low-order word, and the blue color in the low-order byte of the high-order word."
actually, when converting individual component values back into a compound, you should use RGB() macro rather than doing it 'the hard way'.
If you're talking about actual videomemory, then the above may not even be correct at all. There are videocards where there memorylayout is BGR, and I've even seen BRG
typically there'll be either a padding byte or an alpha byte in there. though there are videocards that actually have 3 bytes per pixel.