code specifc; byte into int

HDC hWindowDC = ::GetDC(hWnd);
(?)          COLORREF GetPixel(   HDC hWindowDC, int x, int y );

I have problem with the (?) part.
what type of variable do I use to store data from getpixel?

also, how do I convert those values into

int red
int green
int blue

Who is Participating?
Jaime OlivaresConnect With a Mentor Software ArchitectCommented:
Jaime OlivaresSoftware ArchitectCommented:
COLORREF is a 32-bit value
TroudeloupAuthor Commented:
ok so I do

COLORREF pixel_color = GetPixel(   HDC hWindowDC, int x, int y );

and then
uh i never did this conversion before,

how do I do it?
Jaime OlivaresSoftware ArchitectCommented:
you can use as COLORREF color = GetPixel(......)
if you want to know independent color GetRValue(), GetGValue() and GetBValue() as

COLORREF color = GetPixel(someHDC, 50, 50); // just an example
int blue = GetBValue(color);

More help here:

TroudeloupAuthor Commented:
int blue = GetBValue(color);

got it

how do you pro guys find all of these information?  it would be crazy if i think you are born with it.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.