GetPixel

2.x

  COLORREF GetPixel(hdc, nXPos, nYPos)    
  HDC hdc; /* handle of device context */
  int nXPos; /* x-coordinate of pixel to retrieve */
  int nYPos; /* y-coordinate of pixel to retrieve */

The GetPixel function retrieves the RGB (red, green, blue) color value of the pixel at the specified coordinates. The point must be in the clipping region; if it is not, the function is ignored.

Parameters

hdc

Identifies the device context.

nXPos

Specifies the logical x-coordinate of the point to be examined.

nYPos

Specifies the logical y-coordinate of the point to be examined.

Return Value

The return value specifies an RGB color value for the color of the given point, if the function is successful. It is –1 if the coordinates do not specify a point in the clipping region.

Comments

Not all devices support the GetPixel function. For more information, see the description of the GetDeviceCaps function.

See Also

GetDeviceCaps, SetPixel