PDA

View Full Version : Color Macro



06-17-2000, 11:53 PM
Hello, here's my problem.
Say i have a 24 bits color in a unsigned long integer, using the following format (R = RED, B = BLUE, G = GREEN):

010101100011100110011001
RRRRRRRRGGGGGGGGBBBBBBBB

I found that how to extract the blue and the red component, but i can't figure out how to extract the green component. Anyone knows a macro to do that?

Thanx a lot, fLOrK.

Bob
06-18-2000, 01:04 AM
I assume you use bitshift to extract red, and bitmasking to extract blue. To extract green, you must use a combination of these two methods. First shift, then mask, like this.

green = (color >> 8) & 0x000000FF;

green is your green component, and color is your original RGB color.

06-18-2000, 09:29 AM
Thanks a lot