Bitmap::InitializePalette method

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


Status InitializePalette(
  IN OUT ColorPalette *palette,
  PaletteType         palettetype,
  INT                 optimalColors,
  BOOL                useTransparentColor,
  Bitmap              *bitmap



Type: ColorPalette*

Pointer to a buffer that contains a ColorPalette structure followed by an array of ARGB values. 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)).


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.


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.


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.


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: 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.


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