ErrorDiffusionDithererFloydSteinberg Property

Gets an ErrorDiffusionDitherer instance using the original filter proposed by Floyd and Steinberg in 1975 when they came out with the idea of error diffusion dithering. Uses a small, 3x2 matrix so the processing is somewhat faster than by the other alternatives.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 8.1.0
C#
public static ErrorDiffusionDitherer FloydSteinberg { get; }

Property Value

ErrorDiffusionDitherer

Example

The following example demonstrates how to use the ditherer returned by this property:
C#
public static IReadWriteBitmapData ToDitheredFloydSteinberg(IReadWriteBitmapData source, IQuantizer quantizer)
{
    IDitherer ditherer = ErrorDiffusionDitherer.FloydSteinberg;

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

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

The example above may produce the following results:

Original image
Quantized 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 Floyd-Steinberg dithering
Quantizing with black and white palette

Shield icon with transparent background
Shield icon with transparency

Test image "Cameraman"
Original test image "Cameraman"

Test image "Cameraman" with 2 BPP grayscale palette using Floyd-Steinberg dithering
Quantizing with grayscale 4 color palette

Test image "Cameraman" with black and white palette using Floyd-Steinberg dithering
Quantizing with black and white palette

Test image "Lena"
Original test image "Lena"

Test image "Lena" with RGB332 palette using direct color mapping and Floyd-Steinberg dithering
Quantizing with RGB 332 palette

Test image "Lena" with RGB111 palette and Floyd-Steinberg dithering
Quantizing with custom 8-color palette

See Also