Thread: getting pixel information

  1. #1
    Registered User
    Join Date
    Mar 2004

    getting pixel information


    Does anyone know how to retrieve the pixel color information for any particular pixel on the screen? I know it works with bitmaps using unsigned getpixel (int x, int y); but I need a function to retrieve any pixel. Is this even possible?

  2. #2
    Details, details, give us some details!

    What graphics API are you using?

  3. #3
    Registered User
    Join Date
    Mar 2004
    Graphics API? Uh. . .win32, I guess. I'm not vying for the Turing Award, I just want to know if there's a function for getting pixel info.

  4. #4
    Join Date
    Jan 2002
    Posting this question on the windows board might have been a better idea but, given the current hideous state of the boards, posting just about anywhere is going to be horrible. (<-- at least this guy still looks 'normal' ... edit: well, he started off normal but has verily become possess-ed by demons.)

    You can use GetPixel provided you have a handle to the desktop device context which can be obtained by using CreateDC:
    /*eg. get colour at current pixel coordinates*/
    COLORREF clr;
    HDC      hdcScrn;
    POINT    pt;
    At least that code block didn't get nasty scrollbars inserted...
    Last edited by Ken Fitlike; 03-28-2004 at 03:04 AM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Registered User
    Join Date
    Mar 2004


    Works great, Ken. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 06-01-2009, 07:54 PM
  2. How can I make this code more elegant?
    By ejohns85 in forum C++ Programming
    Replies: 3
    Last Post: 04-02-2009, 08:55 AM
  3. Assignment Help !! (Student information system)
    By ashb in forum C++ Programming
    Replies: 6
    Last Post: 03-12-2005, 05:32 AM
  4. Going out of scope
    By nickname_changed in forum C++ Programming
    Replies: 9
    Last Post: 10-12-2003, 06:27 PM
  5. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-20-2002, 11:35 PM