SetPixel

2.x

  COLORREF SetPixel(hdc, nXPos, nYPos, clrref)    
  HDC hdc; /* handle of device context */
  int nXPos; /* x-coordinate of pixel to set */
  int nYPos; /* y-coordinate of pixel to set */
  COLORREF clrref; /* color of set pixel */

The SetPixel function sets the pixel at the specified coordinates to the closest approximation of the given color. The point must be in the clipping region; if it is not, the function does nothing.

Parameters

hdc

Identifies the device context.

nXPos

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

nYPos

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

clrref

Specifies the color to be used to paint the point.

Return Value

The return value is the RGB value for the color the point is painted, if the function is successful. This value can be different from the specified value if an approximation of that color is used. The return value is –1 if the function fails (if the point is outside the clipping region).

Comments

Not all devices support the SetPixel function. To discover whether a device supports raster operations, an application can call the GetDeviceCaps function using the RC_BITBLT index.

See Also

GetDeviceCaps, GetPixel