Color Macro

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.

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.

Thanks a lot