Hi,
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?
Hi,
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?
Details, details, give us some details!
What graphics API are you using?
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.
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:
At least that code block didn't get nasty scrollbars inserted...Code:/*eg. get colour at current pixel coordinates*/ COLORREF clr; HDC hdcScrn; POINT pt; GetCursorPos(&pt); hdcScrn=CreateDC("DISPLAY",0,0,0); clr=GetPixel(hdcScrn,pt.x,pt.y); DeleteDC(hdcScrn);
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.
Works great, Ken. Thanks.