public static PredefinedColorsQuantizer Rgb555(
Color32 backColor = default,
byte alphaThreshold = 128
)
Public Shared Function Rgb555 (
Optional backColor As Color32 = Nothing,
Optional alphaThreshold As Byte = 128
) As PredefinedColorsQuantizer
public:
static PredefinedColorsQuantizer^ Rgb555(
Color32 backColor = Color32(),
unsigned char alphaThreshold = 128
)
static member Rgb555 :
?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 32,768 colors.
This quantizer fits well for the Format16bppRgb555 pixel format.
public static IReadWriteBitmapData ToRgb555(IReadWriteBitmapData source, Color32 backColor = default, IDitherer ditherer = null)
{
IQuantizer quantizer = PredefinedColorsQuantizer.Rgb555(backColor);
// a.) this solution returns a new bitmap data and does not change the original one:
return source.Clone(KnownPixelFormat.Format16bppRgb555, quantizer, ditherer);
// b.) when converting to Format16bppRgb555 format without dithering, this produces the same result:
if (ditherer == null)
return source.Clone(KnownPixelFormat.Format16bppRgb555, backColor);
// c.) alternatively, you can perform the quantizing 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 |
---|---|
|
|
|
|