Thread: Finding the color of any pixel on screen

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Kirdra's Avatar
    Join Date
    Aug 2002
    Posts
    105

    Finding the color of any pixel on screen

    I need to find the color of any/all pixel/s on the screen. The code I got so far seems to do that but it doesn't get the pixel of my game window (another program, direct draw window app).

    Here is the code...

    Code:
    POINT pt;
    GetCursorPos(&pt);		
    		
    HDC hdc = GetDC(0);
    	
    COLORREF pixel = GetPixel(hdc, pt.x, pt.y);
    
    ReleaseDC(0, hdc);
    
    cout << " red: " << (int)GetRValue(pixel)
           << " green: " << (int)GetGValue(pixel) 
           << " blue : " << (int)GetBValue(pixel) << '\n';
    The idea of the program is to place the cursor over some color and the program will show you the values for that color.
    Last edited by Kirdra; 11-09-2007 at 01:18 PM. Reason: fixed something

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. finding the screen coordinates of a pixel
    By ShadowBeast in forum C# Programming
    Replies: 7
    Last Post: 04-27-2007, 05:42 AM
  2. Getting Pixel Colour Screen
    By god_of_war in forum C++ Programming
    Replies: 3
    Last Post: 03-14-2006, 01:17 PM
  3. Feedback: Functional Specification Wording
    By Ragsdale85 in forum C++ Programming
    Replies: 0
    Last Post: 01-18-2006, 04:56 PM
  4. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 10:18 PM
  5. i am not able to figure ot the starting point of this
    By youngashish in forum C++ Programming
    Replies: 7
    Last Post: 10-07-2004, 02:41 AM