Note
This example requires to reference the KGySoft.Drawing package. When targeting .NET 7 or later it can be executed on Windows only.
public static OptimizedPaletteQuantizer Wu(
int maxColors = 256,
Color backColor = default,
byte alphaThreshold = 128
)
Public Shared Function Wu (
Optional maxColors As Integer = 256,
Optional backColor As Color = Nothing,
Optional alphaThreshold As Byte = 128
) As OptimizedPaletteQuantizer
public:
static OptimizedPaletteQuantizer^ Wu(
int maxColors = 256,
Color backColor = Color(),
unsigned char alphaThreshold = 128
)
static member Wu :
?maxColors : int *
?backColor : Color *
?alphaThreshold : byte
(* Defaults:
let _maxColors = defaultArg maxColors 256
let _backColor = defaultArg backColor new Color()
let _alphaThreshold = defaultArg alphaThreshold 128
*)
-> OptimizedPaletteQuantizer
Bitmap bmpOriginal = Icons.Shield.ExtractBitmap(new Size(256, 256));
bmpOriginal.SaveAsPng(@"c:\temp\original.png");
IQuantizer quantizer = OptimizedPaletteQuantizer.Wu(256);
Bitmap bmpConverted = bmpOriginal.ConvertPixelFormat(PixelFormat.Format8bppIndexed, quantizer);
bmpConverted.SaveAsGif(@"c:\temp\converted.gif");
The example above produces the following result:
original.png | |
converted.gif |
ArgumentOutOfRangeException | maxColors must be between 2 and 65536, inclusive bounds. |