QuantizeOptions Class
Immutable options of a color reduction to a palette: by ImageProcessingExtensions.Quantize, and by the encoders that store a palette (GifEncoder.Quantization, BmpEncoder.Quantization and PngEncoder.Quantization).
public sealed class QuantizeOptionsRemarks
Without QuantizeOptions.Palette, each frame gets its own palette of at most QuantizeOptions.MaxColors entries: the exact colors of the frame when they fit, otherwise a deterministic variance-based median cut of its colors (see PaletteBuilder). With QuantizeOptions.Palette, every frame maps to that palette, which is how the frames of an animation share one palette. A frame whose colors are all palette entries is reproduced exactly, whatever the dithering.
The reduction is deterministic: the same pixels and options give the same output on every platform.
Constructors
| Name | Description |
|---|---|
| QuantizeOptions() |
QuantizeOptions()
QuantizeOptions.cspublic QuantizeOptions()No documentation is available.
Properties
| Name | Description |
|---|---|
| Default | Gets the default options: at most 256 colors per frame, without dithering. |
| DitherStrength | Gets the strength of the dithering, from 0 (no dithering) to 1 (the full error is diffused, or the full pattern added). Defaults to 1. It is applied in 256ths. |
| Dithering | Gets the dithering applied when a frame has colors that are not palette entries. Defaults to DitheringMode.None. |
| MaxColors | Gets the largest number of palette entries of a frame, including the transparent entry when the frame has transparent pixels. Defaults to 256. Ignored when QuantizeOptions.Palette is set. An encoder may lower it further: the indexed BMP layouts hold 2, 16 or 256 entries. |
| Palette | Gets a fixed palette every frame maps to, or null (the default) to compute the palette of each frame. Build a palette shared by several frames or images with PaletteBuilder. |
Default
QuantizeOptions.csGets the default options: at most 256 colors per frame, without dithering.
public static QuantizeOptions Default { get; }Property value
DitherStrength
QuantizeOptions.csGets the strength of the dithering, from 0 (no dithering) to 1 (the full error is diffused, or the full pattern added). Defaults to 1. It is applied in 256ths.
public double DitherStrength { get; init; }Dithering
QuantizeOptions.csGets the dithering applied when a frame has colors that are not palette entries. Defaults to DitheringMode.None.
public DitheringMode Dithering { get; init; }MaxColors
QuantizeOptions.csGets the largest number of palette entries of a frame, including the transparent entry when the frame has transparent pixels. Defaults to 256. Ignored when QuantizeOptions.Palette is set. An encoder may lower it further: the indexed BMP layouts hold 2, 16 or 256 entries.
public int MaxColors { get; init; }Palette
QuantizeOptions.csGets a fixed palette every frame maps to, or null (the default) to compute the palette of each frame. Build a palette shared by several frames or images with PaletteBuilder.
public ImagePalette? Palette { get; init; }