PredefinedColorsQuantizerFromPixelFormat Method

Gets a PredefinedColorsQuantizer instance that is compatible with the specified pixelFormat.
See the Remarks section for details.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 9.0.0
C#
public static PredefinedColorsQuantizer FromPixelFormat(
	KnownPixelFormat pixelFormat,
	Color32 backColor = default,
	byte alphaThreshold = 128
)

Parameters

pixelFormat  KnownPixelFormat
The KnownPixelFormat to get a compatible quantizer for.
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)
Specifies a threshold value for the Color32.A field, under which a quantized color is considered completely transparent. This parameter is optional.
Default value: 128.

Return Value

PredefinedColorsQuantizer
A PredefinedColorsQuantizer instance that is compatible with the specified pixelFormat.

Remarks

If pixelFormat is Format24bppRgb, Format32bppRgb, Format48bppRgb or Format96bppRgb, then this method returns the same quantizer as the Rgb888 method.

If pixelFormat is Format16bppArgb1555, then this method returns the same quantizer as the Argb1555 method.

If pixelFormat is Format16bppRgb565, then this method returns the same quantizer as the Rgb565 method.

If pixelFormat is Format16bppRgb555, then this method returns the same quantizer as the Rgb555 method.

If pixelFormat is Format8bppGrayScale, Format16bppGrayScale or Format32bppGrayScale, then this method returns the same quantizer as the Grayscale method.

If pixelFormat is Format8bppIndexed, then this method returns the same quantizer as the SystemDefault8BppPalette method.

If pixelFormat is Format4bppIndexed, then this method returns the same quantizer as the SystemDefault4BppPalette method.

If pixelFormat is Format1bppIndexed, then this method returns the same quantizer as the SystemDefault1BppPalette method.

In any other case than the ones above this method the same quantizer as the Argb8888 method.

  Note

For examples see the Examples section of the mentioned methods above.

See Also