Upravit

Sdílet prostřednictvím


Bitmap::InitializePalette method (gdiplusheaders.h)

The Bitmap::InitializePalette method initializes a standard, optimal, or custom color palette.

Syntax

Status InitializePalette(
  [in, out] ColorPalette *palette,
  [in]      PaletteType  palettetype,
  [in]      INT          optimalColors,
  [in]      BOOL         useTransparentColor,
  [in]      Bitmap       *bitmap
);

Parameters

[in, out] palette

Type: ColorPalette*

Pointer to a buffer that contains a ColorPalette structure followed by an array of ARGB values. You must set the Flags and Count members of the ColorPalette structure. The Entries member of a ColorPalette structure is an array of one ARGB value. You must allocate memory for the ColorPalette structure and for the additional ARGB values in the palette. For example, if the palette has 36 ARGB values, allocate a buffer as follows: malloc(sizeof(ColorPalette) + 35*sizeof(ARGB)).

[in] palettetype

Type: PaletteType

Element of the PaletteType enumeration that specifies the palette type. The palette can have one of several standard types, or it can be a custom palette that you define. Also, the Bitmap::InitializePalette method can create an optimal palette based on a specified bitmap.

[in] optimalColors

Type: INT

Integer that specifies the number of colors you want to have in an optimal palette based on a specified bitmap. If this parameter is greater than 0, the palettetype parameter must be set to PaletteTypeOptimal, and the bitmap parameter must point to a Bitmap object. If you are creating a standard or custom palette rather than an optimal palette, set this parameter to 0.

[in] useTransparentColor

Type: BOOL

Boolean value that specifies whether to include the transparent color in the palette. Set to TRUE to include the transparent color; otherwise FALSE.

[in] bitmap

Type: Bitmap*

Pointer to a Bitmap object for which an optimal palette will be created. If palettetype is set to PaletteTypeOptimal and optimalColors is set to a positive integer, set this parameter to the address of a Bitmap object. Otherwise, set this parameter to NULL.

Return value

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header gdiplusheaders.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Bitmap