The GetNearestPaletteIndex function retrieves the index for the entry in the specified logical palette most closely matching a specified color value.
UINT GetNearestPaletteIndex(
HPALETTE hpal, |
// handle of logical color palette |
COLORREF crColor |
// color to be matched |
); |
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. To get extended error information, call GetLastError.
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.
GetDeviceCaps, GetNearestColor, GetPaletteEntries, GetSystemPaletteEntries, COLORREF