ColorPaletteType constructor.
Syntax

[C#]

ColorPaletteType();
ColorPaletteType(ColorPaletteFamily inDefinition);
ColorPaletteType(ColorPaletteFamily inDefinition, int inMaxSize);

[Visual Basic]

Sub New()
Sub New(inDefinition As ColorPaletteFamily)
Sub New(inDefinition As ColorPaletteFamily, inMaxSize As Integer)
Params
Name Description
inDefinition The type of palette.
inMaxSize The maximum number of colors for the palette.
Notes

Create a palette by specifying the palette definition. If no definition is specified the palette will default to an Adaptive palette.

See Also

ColorPaletteFamily

Example

Here we convert a jpeg image into GIF, reducing its colors to 16 and making sure that white, black, red and green are included in the final output.

[C#]using (Bitmap bm = (Bitmap)Bitmap.FromFile(Server.MapPath("rez/jeremy-bishop-_CFv3bntQlQ-unsplash.jpg"))) {
  ColorPaletteType plt = new ColorPaletteType(ColorPaletteFamily.Exact) { MaxSize = 16 };
  plt.FixedColors = new List<Color>(new Color[] { Color.White, Color.Black, Color.Red, Color.Green });
  EncoderParameters pars = new EncoderParameters() { Palette = plt };
  bm.Save(Server.MapPath("IG8_Palette_70.gif"), ImageFormat.Gif, pars);
}



jeremy-bishop-_CFv3bntQlQ-unsplash.jpg


IG8_Palette_70.gif