PredefinedColorsQuantizerFromCustomPalette(IEnumerableColor32, Color32, 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(
	IEnumerable<Color32> palette,
	Color32 backColor = default,
	byte alphaThreshold = 128
)

Parameters

palette  IEnumerableColor32
The array of colors to be used by the returned instance.
backColor  Color32  (Optional)
Colors with alpha (transparency), which are considered opaque will be blended with this color before quantizing. The Color32.A field of the background color is ignored. This parameter is optional.
Default value: The default value of the Color32 type, which has the same RGB values as Color.Black.
alphaThreshold  Byte  (Optional)
If the specified palette contains a transparent color, then specifies a threshold value for the Color32.A field, 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