Jump to content
  • Advertisement
Sign in to follow this  
archr926

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

This topic is 4993 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!