GetPixel function (wingdi.h)
The GetPixel function retrieves the red, green, blue (RGB) color value of the pixel at the specified coordinates.
Syntax
COLORREF GetPixel(
[in] HDC hdc,
[in] int x,
[in] int y
);
Parameters
[in] hdc
A handle to the device context.
[in] x
The x-coordinate, in logical units, of the pixel to be examined.
[in] y
The y-coordinate, in logical units, of the pixel to be examined.
Return value
The return value is the COLORREF value that specifies the RGB of the pixel. If the pixel is outside of the current clipping region, the return value is CLR_INVALID (0xFFFFFFFF defined in Wingdi.h).
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.
A bitmap must be selected within the device context, otherwise, CLR_INVALID is returned on all pixels.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | wingdi.h (include Windows.h) |
Library | Gdi32.lib |
DLL | Gdi32.dll |