Export (0) Print
Expand All

Bitmap.InitializePalette method

Applies to: desktop apps only

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

Syntax

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

Parameters

palette [out]

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

palettetype [in]

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.

optimalColors [in]

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.

useTransparentColor [in]

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.

bitmap [in]

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.

Examples

For an example, see Bitmap::ConvertFormat.

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Product

GDI+ 1.1

Header

GdiplusBitmap.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

Bitmap

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show:
© 2014 Microsoft