PredefinedColorsQuantizerFromCustomFunction(FuncColor32, Color32, Color32, Byte, Boolean, KnownPixelFormat) Method

Gets a PredefinedColorsQuantizer instance that can quantize colors using the custom quantizer function specified in the quantizingFunction parameter.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 9.0.0
C#
public static PredefinedColorsQuantizer FromCustomFunction(
	Func<Color32, Color32> quantizingFunction,
	Color32 backColor,
	byte alphaThreshold,
	bool autoBlend,
	KnownPixelFormat pixelFormatHint = KnownPixelFormat.Format32bppArgb
)

Parameters

quantizingFunction  FuncColor32, Color32
A delegate that specifies the custom quantizing logic. It must be thread-safe for parallel invoking, and it is expected to be fast. The results returned by the delegate are not cached.
backColor  Color32
Determines the BackColor property of the result. The Color32.A field of the background color is ignored.
If autoBlend is , then colors with alpha (transparency), whose Color32.A field is equal to or greater than alphaThreshold will be blended with this color before invoking the quantizingFunction delegate.
If autoBlend is , then this parameter matters only if a consumer considers the BackColor property, such as an IDitherer instance that does not support partial transparency.
alphaThreshold  Byte
Specifies a threshold value for the Color32.A field, under which a quantized color is considered transparent without invoking quantizingFunction.
If autoBlend is , then quantizingFunction will never be invoked with colors with alpha. Instead, colors whose alpha equal to or greater than this parameter will be blended with backColor before invoking quantizingFunction.
If autoBlend is , then colors with alpha equal to or greater than this parameter are allowed to be passed to quantizingFunction without blending with backColor.
autoBlend  Boolean
to always apply backColor and alphaThreshold to the input color before invoking quantizingFunction.
to apply only alphaThreshold to the input colors and allowing quantizingFunction to be invoked with partially transparent colors.
pixelFormatHint  KnownPixelFormat  (Optional)
The KnownPixelFormat value that the PixelFormatHint property of the returned instance will return. This parameter is optional.
Default value: Format32bppArgb.

Return Value

PredefinedColorsQuantizer
A PredefinedColorsQuantizer instance that can quantize colors using the custom quantizer function specified in the quantizingFunction parameter.

See Also