InterleavedGradientNoiseDitherer Constructor

KGy SOFT Drawing Libraries Help
Initializes a new instance of the InterleavedGradientNoiseDitherer class.
See the Examples section for some examples.

Namespace:  KGySoft.Drawing.Imaging
Assembly:  KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 5.1.0
Syntax

public InterleavedGradientNoiseDitherer(
	float strength = 0f
)

Parameters

strength (Optional)
Type: SystemSingle
The strength of the dithering effect between 0 and 1 (inclusive bounds). Specify 0 to use an auto value for each dithering session based on the used quantizer.
See the Remarks section of the OrderedDitherer class for more details and some examples regarding dithering strength. The same applies also for the InterleavedGradientNoiseDitherer class. This parameter is optional.
Default value: 0.
Examples

The following example demonstrates how to use the InterleavedGradientNoiseDitherer class.
C#
public static Bitmap ToDitheredInterleavedGradientNoise(Bitmap source, IQuantizer quantizer)
{
    IDitherer ditherer = new InterleavedGradientNoiseDitherer();

    // a.) this solution returns a new bitmap and does not change the original one:
    return source.ConvertPixelFormat(quantizer.PixelFormatHint, quantizer, ditherer);

    // b.) alternatively, you can perform the dithering directly on the source bitmap:
    source.Dither(quantizer, ditherer);
    return source;
}

The example above may produce the following results:

Original imageQuantized and dithered image

Color hues with alpha gradient
Color hues with alpha gradient

Grayscale color shades with different bit depths
Grayscale color shades

Grayscale color shades with black and white palette using interleaved gradient noise dithering
Quantizing with black and white palette

See Also

Reference