|
-
Jun 19th, 2001, 02:39 PM
#1
Thread Starter
Hyperactive Member
Colors
How do i work with colors? I read on the MSDN that you can have a RGB macro or COLORREF, but it does not work. Can anyone please give me an example of how to make them work? Thanks
Amon Ra
The Power of Learning.
-
Jun 19th, 2001, 03:14 PM
#2
COLOREF is a type of variable. It holds a color.
Code:
COLORREF ColorRef;
ColorRef = RGB(RedValue, GreenValue, BlueValue);
Then if you want to get the red green and blue values out of ColorRef, use GetRValue, GetGValue, GetBValue.
Does that answer your question? If not, let me know.
-
Jun 19th, 2001, 05:50 PM
#3
Monday Morning Lunatic
As a matter of course, whenever you encounter a new type, always look it up in the header files for the exact definition. COLORREF is actually an unsigned long (surprised?) and if you look at RGB you can just see how it's packing the 3 bytes into a 4-byte long 
I don't have any practical information, but it's a useful tidbit
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 19th, 2001, 10:00 PM
#4
Thread Starter
Hyperactive Member
...
Thanks for the tip Pars', but thinking about it, I am not so sure about how the x-bit work. How the memory is allocated differently for them... Could you(or someone else) explain to me ? Thanks a lot
Amon Ra
The Power of Learning.
-
Jun 20th, 2001, 03:18 AM
#5
Monday Morning Lunatic
Ok. RGB is a macro, so it's expanded at preprocess time (during compilation). If you look at it it's just doing shifting and OR-ing on the individual bytes, so that the 3 bytes you want are stored within the 4-byte long value, and can be moved around as one, with no worries
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
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
|