View Full Version : Color Macro

06-18-2000, 12:53 AM
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):


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.

06-18-2000, 02: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, 10:29 AM
Thanks a lot