public static PredefinedColorsQuantizer Rgb888(
Color32 backColor = default,
byte alphaThreshold = 128
)
Public Shared Function Rgb888 (
Optional backColor As Color32 = Nothing,
Optional alphaThreshold As Byte = 128
) As PredefinedColorsQuantizer
public:
static PredefinedColorsQuantizer^ Rgb888(
Color32 backColor = Color32(),
unsigned char alphaThreshold = 128
)
static member Rgb888 :
?backColor : Color32 *
?alphaThreshold : byte
(* Defaults:
let _backColor = defaultArg backColor new Color32()
let _alphaThreshold = defaultArg alphaThreshold 128
*)
-> PredefinedColorsQuantizer
The returned PredefinedColorsQuantizer instance can return up to 2563 (16,777,216) colors. It practically just removes transparency and does not change colors without alpha.
This quantizer fits well for the Format24bppRgb pixel format.
public static IReadWriteBitmapData ToRgb888(IReadWriteBitmapData source, Color32 backColor = default)
{
IQuantizer quantizer = PredefinedColorsQuantizer.Rgb888(backColor);
// a.) this solution returns a new bitmap data and does not change the original one:
return source.Clone(KnownPixelFormat.Format24bppRgb, quantizer);
// b.) when converting to Format24bppRgb format, this produces the same result:
return source.Clone(KnownPixelFormat.Format24bppRgb, backColor);
// c.) alternatively, you can perform the quantizing directly on the source bitmap data:
source.Quantize(quantizer);
return source;
}
The example above may produce the following results:
Original image | Quantized image |
---|---|
|
|
|
|