-
September 23rd, 2004, 08:57 AM
#1
Convert COLORREF to RGB???
Is there a way to convert a COLORREF value into the three RGB ints?
-B
-
September 23rd, 2004, 09:07 AM
#2
Re: Convert COLORREF to RGB???
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.
-
September 23rd, 2004, 11:22 AM
#3
Re: Convert COLORREF to RGB???
may be you can stop amazing yourself by reading the documentation!!
and Canada rocks!! Peace bro.
-
September 23rd, 2004, 11:26 AM
#4
Re: Convert COLORREF to RGB???
Yeah, but who has time for that.
-
September 23rd, 2004, 12:27 PM
#5
Re: Convert COLORREF to RGB???
Reading the documentation?? That's cheating isn't it???
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
September 23rd, 2004, 12:39 PM
#6
Re: Convert COLORREF to RGB???
-
March 10th, 2015, 06:55 PM
#7
Re: Convert COLORREF to RGB???
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."
-
March 11th, 2015, 02:27 AM
#8
Re: Convert COLORREF to RGB???
Originally Posted by David Carr
Don't forget the following when looking at the different bytes of an integer
Are you sure OP needs your "tip" after 10.5 years?
Victor Nijegorodov
-
March 11th, 2015, 07:41 AM
#9
Re: Convert COLORREF to RGB???
Originally Posted by David Carr
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|