public static PredefinedColorsQuantizer SystemDefault8BppPalette(
Color backColor = default,
byte alphaThreshold = 128
)
Public Shared Function SystemDefault8BppPalette (
Optional backColor As Color = Nothing,
Optional alphaThreshold As Byte = 128
) As PredefinedColorsQuantizer
public:
static PredefinedColorsQuantizer^ SystemDefault8BppPalette(
Color backColor = Color(),
unsigned char alphaThreshold = 128
)
static member SystemDefault8BppPalette :
?backColor : Color *
?alphaThreshold : byte
(* Defaults:
let _backColor = defaultArg backColor new Color()
let _alphaThreshold = defaultArg alphaThreshold 128
*)
-> PredefinedColorsQuantizer
The returned PredefinedColorsQuantizer instance can return up to 256 colors. Actually this amount is somewhat smaller because of some redundant entries in the palette.
This quantizer fits well for the Format8bppIndexed pixel format.
The palette of this quantizer contains transparent entries.
public static IReadWriteBitmapData ToDefault8Bpp(IReadWriteBitmapData source, Color backColor = default,
byte alphaThreshold = 128, IDitherer ditherer = null)
{
IQuantizer quantizer = PredefinedColorsQuantizer.SystemDefault8BppPalette(backColor, alphaThreshold);
// 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 Format8bppIndexed format without dithering, this produces the same result:
if (ditherer == null)
return source.Clone(KnownPixelFormat.Format8bppIndexed, backColor, alphaThreshold);
// 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 |
---|---|
|
|
|
|
|
|
|