RandomNoiseDitherer Constructor

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

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

public RandomNoiseDitherer(
	float strength = 0f,
	int? seed = null


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 RandomNoiseDitherer class. This parameter is optional.
Default value: 0.
seed (Optional)
Type: SystemNullableInt32
If , then a ThreadSafeRandom instance will be used internally with a time-dependent seed value, and the dithering session will allow parallel processing. If not , then a Random instance will be created for each dithering session with the specified seed, and the dithering session will not allow parallel processing.

The following example demonstrates how to use the RandomNoiseDitherer class.
public static Bitmap ToDitheredRandomNoise(Bitmap source, IQuantizer quantizer)
    IDitherer ditherer = new RandomNoiseDitherer();

    // 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 random noise dithering
Quantizing with black and white palette

See Also