Method CreatePaletteFromBitmap
- Namespace
 - PaintDotNet.Imaging
 
- Assembly
 - PaintDotNet.Windows.dll
 
CreatePaletteFromBitmap(IBitmapSource, int, bool)
Initializes a palette using a computed optimized values based on the reference bitmap.
IPalette CreatePaletteFromBitmap(IBitmapSource bitmap, int colorCount, bool addTransparentColor)
Parameters
bitmapIBitmapSourceThe source bitmap.
colorCountintThe number of colors to initialize the palette with.
addTransparentColorboolA value to indicate whether to add a transparent color.
Returns
Remarks
The resulting palette contains the specified number of colors which best represent the colors present
in the bitmap. The algorithm operates on the opaque RGB color value of each pixel in the reference
bitmap and hence ignores any alpha values. If a transparent color is required, set the addTransparentColor
to true and one fewer optimized color will be computed, reducing the colorCount, and a fully transparent
color entry will be added.
This method uses the Median Cut algorithm for palette generation.
This method is a wrapper around IWICPalette::InitializeFromBitmap().