public IDitherer? Ditherer { get; set; }
Public Property Ditherer As IDitherer
Get
Set
public:
property IDitherer^ Ditherer {
IDitherer^ get ();
void set (IDitherer^ value);
}
member Ditherer : IDitherer with get, set
If the target IReadWriteBitmapData does not support the color depth of the drawn shape, or when Quantizer is also set, setting a ditherer can help to preserve the original details.
If Quantizer is , and the target IReadWriteBitmapData is not a low-color bitmap, then this property might be ignored.
The following example demonstrates how to draw a shape with dithering:
public IReadWriteBitmapData CreateBlackAndWhiteDrawing(IDitherer? ditherer)
{
// Creating a 1bpp image, which has a black white palette by default
IReadWriteBitmapData bmp = BitmapDataFactory.CreateBitmapData(100, 100, KnownPixelFormat.Format1bppIndexed);
// Clearing the image with Cyan, using the ditherer
bmp.Clear(Color.Cyan, ditherer);
// Specifying a path with a star shape, translated to the center of the 100 x 100 bitmap
var path = new Path(false)
.TransformTranslation(1, 5)
.AddPolygon(new(50, 0), new(79, 90), new(2, 35), new(97, 35), new(21, 90));
// Filling the star shape with a blue brush
bmp.FillPath(Color.Blue, path, new DrawingOptions { Ditherer = ditherer });
return bmp;
}
The example above may produce the following results:
Description | Image Example |
---|---|
Ditherer is . The colors are automatically quantized to the black and white target. Cyan becomes white, whereas blue becomes black. | ![]() |
Using InterleavedGradientNoiseDitherer. The shades of cyan and blue appear in dithering patterns. | ![]() |
Using BlueNoise dithering. The shades of cyan and blue appear in dithering patterns. | ![]() |