Advertisement

COLORREF information

Started by October 27, 2001 05:26 PM
1 comment, last by kmsixpence 23 years ago
I''m sorry, but I would like to ask another Q. I use GetPixel to get the pixel at a location. I have it stored in a COLORREF. How would you read each indivual color(red, green , blue) and store it in 3 seperate ints?
can anyone tell me?
Advertisement
I''ll give it a try.

According to the MSDN the colorref value is stored like this:

0x00bbggrr

  COLORREF pixel;int      red, green, blue;red = pixel & 0xFF;pixel = pixel >> 8;green = pixel & 0xFF;pixel = pixel >> 8;blue = pixel & 0xFF;  


The code might be all wrong but I think the general idea is that you have to use the bitwise and shift operators.

This topic is closed to new replies.

Advertisement