PredefinedColorsQuantizerFromCustomPalette(Color, Color, Byte) Method

Gets a PredefinedColorsQuantizer instance that can quantize colors using the colors in the specified palette.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 9.1.1
C#
public static PredefinedColorsQuantizer FromCustomPalette(
	Color[] palette,
	Color backColor = default,
	byte alphaThreshold = 128
)

Parameters

palette  Color
The array of colors to be used by the returned instance.
backColor  Color  (Optional)
Colors with alpha (transparency), which are considered opaque will be blended with this color before quantizing. The Color.A property of the background color is ignored. This parameter is optional.
Default value: Empty, which has the same RGB values as Black.
alphaThreshold  Byte  (Optional)
If the specified palette contains a transparent color, then specifies a threshold value for the Color.A property, under which a quantized color is considered transparent. If 0, then the quantized colors will never be transparent. This parameter is optional.
Default value: 128.

Return Value

PredefinedColorsQuantizer
A PredefinedColorsQuantizer instance that can quantize colors using the colors in the specified palette.

Remarks

The PredefinedColorsQuantizer instance returned by this method will use a Palette internally, created from the colors specified in the palette parameter. When quantizing, best matching colors might be looked up sequentially and results might be cached.

If a color to be quantized can be mapped to a color index directly, then create a Palette instance explicitly, specifying the custom mapping logic and use the FromCustomPalette(Palette) overload instead.

If a color to be quantized can be transformed to a result color directly, and the quantized result is not needed to be an indexed image, then use the FromCustomFunction overloads instead.

See Also