Sign in to follow this  
archr926

Finding the color of a pixel on the screen (C++)

Recommended Posts

I need to find the color of a pixel on the screen for a C++ program. It has to be able to find a pixel from the whole screen, and not just a certain window. Is there a function for this, or do I have to write a block of code? If I need a block of code, could you give me something to start wit? Normally I would look it up on MSDN, but I can't find the right search terms.

Share this post


Link to post
Share on other sites
Sounds like windows. You can use COLORREF c = GetPixel(HDC, X, Y) to get the color of a pixel at location X, Y on handle HDC. If you can get an HDC to the window you want to cap from, then this will work.

Share this post


Link to post
Share on other sites
To get an HDC to the entire screen, do

HDC hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL);

and then when you're done with it, do

DeleteDC(hdcScreen);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this