Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function retrieves the RGB color value of the pixel at the specified coordinates.

Syntax

COLORREF GetPixel(
  HDC 
hdc, 
  int 
nXPos, 
  int 
nYPos
); 

Parameters

hdc

[in] Handle to the device context.

nXPos

[in] Specifies the logical x-coordinate of the pixel to be examined.

nYPos

[in] Specifies the logical y-coordinate of the pixel to be examined.

Return Value

The RGB value of the pixel indicates success. CLR_INVALID indicates that the pixel is outside of the current clipping region.

Remarks

The pixel must be within the boundaries of the current clipping region.

Not all devices support GetPixel. An application should call GetDeviceCapsto determine whether a specified device supports this function.

Requirements

Header windows.h
Library coredll.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also