次の方法で共有


GetNearestPaletteIndex function

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 hpal,
  _In_ COLORREF crColor
);

Parameters

  • hpal [in]
    A handle to a logical palette.

  • crColor [in]
    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

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

Colors Overview

Color Functions

GetDeviceCaps

GetNearestColor

GetPaletteEntries

GetSystemPaletteEntries

COLORREF

RGB