public static PredefinedColorsQuantizer SystemDefault4BppPalette(
Color backColor = default
)
Public Shared Function SystemDefault4BppPalette (
Optional backColor As Color = Nothing
) As PredefinedColorsQuantizer
public:
static PredefinedColorsQuantizer^ SystemDefault4BppPalette(
Color backColor = Color()
)
static member SystemDefault4BppPalette :
?backColor : Color
(* Defaults:
let _backColor = defaultArg backColor new Color()
*)
-> PredefinedColorsQuantizer
The returned PredefinedColorsQuantizer instance can return up to 16 colors.
This quantizer fits well for the Format4bppIndexed pixel format.
The palette of this quantizer is not expected to contain transparent entries. The palette consists of the 16 standard basic sRGB colors
public static IReadWriteBitmapData ToDefault4Bpp(IReadWriteBitmapData source, Color backColor = default, IDitherer ditherer = null)
{
IQuantizer quantizer = PredefinedColorsQuantizer.SystemDefault4BppPalette(backColor);
// a.) this solution returns a new bitmap data and does not change the original one:
return source.Clone(KnownPixelFormat.Format8bppIndexed, quantizer, ditherer);
// b.) when converting to Format4bppIndexed format without dithering, this produces the same result:
if (ditherer == null)
return source.Clone(KnownPixelFormat.Format4bppIndexed, backColor);
// c.) alternatively, you can perform the quantization directly on the source bitmap data:
if (ditherer == null)
source.Quantize(quantizer);
else
source.Dither(quantizer, ditherer);
return source;
}
The example above may produce the following results:
Original image | Quantized image |
---|---|
|
|
|
|
|
|