Windows
GDI
GetPixel
The GetPixel function retrieves the red, green, blue (
RGB) color value of the pixel at the specified coordinates.
COLORREF GetPixel(
HDC hdc, //
handle to
DC
int nXPos, // x-coordinate of pixel
int nYPos // y-coordinate of pixel
);
Parameters
hdc
[in]
Handle to the device context.
nXPos
[in] Specifies the x-coordinate, in logical units, of the pixel to be examined.
nYPos
[in] Specifies the y-coordinate, in logical units, of the pixel to be examined.
Return Values
The return value is the
RGB value of the pixel. If the pixel is outside of the current clipping region, the return value is CLR_INVALID.
Remarks
The pixel must be within the boundaries of the current clipping region.
Not all devices support GetPixel. An application should call GetDeviceCaps to determine whether a specified device supports this function.
Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Use Gdi32.lib.