Export (0) Print
Expand All

GetPixel function

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 nXPos,
  _In_  int nYPos
);

Parameters

hdc [in]

A handle to the device context.

nXPos [in]

The x-coordinate, in logical units, of the pixel to be examined.

nYPos [in]

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

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Wingdi.h (include Windows.h)

Library

Gdi32.lib

DLL

Gdi32.dll

See also

Bitmaps Overview
Bitmap Functions
COLORREF
GetDeviceCaps
SetPixel

 

 

Community Additions

ADD
Show:
© 2014 Microsoft