GetNearestPaletteIndex function (wingdi.h)

The GetNearestPaletteIndex function retrieves the index for the entry in the specified logical palette most closely matching a specified color value.

Syntax

UINT GetNearestPaletteIndex(
  [in] HPALETTE h,
  [in] COLORREF color
);

Parameters

[in] h

A handle to a logical palette.

[in] color

A color to be matched. To create a COLORREF color value, use the RGB macro.

Return value

If the function succeeds, the return value is the index of an entry in a logical palette.

If the function fails, the return value is CLR_INVALID.

Remarks

An application can determine whether a device supports palette operations by calling the GetDeviceCaps function and specifying the RASTERCAPS constant.

If the given logical palette contains entries with the PC_EXPLICIT flag set, the return value is undefined.

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

See also

COLORREF

Color Functions

Colors Overview

GetDeviceCaps

GetNearestColor

GetPaletteEntries

GetSystemPaletteEntries

RGB