Type Default Value Read Only Static Description
XPalette None No No The palette used when reducing colors.

When reducing colors, there are different ways to choose such colors. This property controls how colors are chosen. We provide the following options:

  • Adaptive. This palette uses fewer colors than specified if the image has limited colors. It uses an optimized Octree algorithm for fast, high quality color reduction.
  • WebSafe. This palette uses a fixed number of colors. Depth is ignored.
  • Windows. This palette uses a fixed number of colors. Depth is ignored.
  • Macintosh. This palette uses a fixed number of colors. Depth is ignored.
  • Uniform. This palette specified a set of uniformly distributed colors. It only exists for 8, 27, 64, 125 and 216 colors and so the number you specify with Depth may be reduced to accommodate this.
  • Grayscale. This palette uses the exact number of gray values specified in Depth - minimum two.
  • Black&White. This palette always uses two colors - black and white.
  • Exact. This is similar to Adaptive except it is optimized to ensure an exact color match wherever possible.

When using Exact or Adaptive, you can append colors separated by colons or semicolons. These colors are fixed colors, which will always by added to the palette. See the example below.

See Also



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


Canvas canvas = new Canvas(Server.MapPath("rez/pic.jpg"));
canvas.Export.Depth = 8;
XColor[] colors = { 
  new XColor(Color.White), 
  new XColor(Color.Black),
  new XColor(Color.Red),
  new XColor(Color.Green) };
canvas.Export.Palette = new XPalette(XPalette.PaletteDefinition.Exact);
canvas.Export.Palette.FixedColors = colors;

[Visual Basic]

Dim canvas As New Canvas(Server.MapPath("rez/pic.jpg"))
canvas.Export.Depth = 8
Dim colors As XColor() = {New XColor(Color.White), New XColor(Color.Black), New XColor(Color.Red), New XColor(Color.Green)}
canvas.Export.Palette = New XPalette(XPalette.PaletteDefinition.Exact)
canvas.Export.Palette.FixedColors = colors