Class Palette
[Guid("00000040-a8f2-4877-ba0a-fd2b6645fb94")]
public class Palette : ComObject
- Inheritance
-
Palette
Constructors
Palette(ImagingFactory)
Initializes a new instance of the Palette class.
public Palette(ImagingFactory factory)
Parameters
factory
ImagingFactoryThe factory.
Palette(nint)
public Palette(nint nativePtr)
Parameters
nativePtr
nint
Properties
ColorCount
Proxy function for the GetColorCount method.
public int ColorCount { get; }
Property Value
IsBlackWhite
Retrieves a value that describes whether the palette is black and white.
public RawBool IsBlackWhite { get; }
Property Value
- RawBool
Remarks
A palette is considered to be black and white only if it contains exactly two entries, one full black (0xFF000000) and one full white (0xFFFFFFF).
IsGrayscale
Retrieves a value that describes whether a palette is grayscale.
public RawBool IsGrayscale { get; }
Property Value
- RawBool
Remarks
A palette is considered grayscale only if, for every entry, the alpha value is 0xFF and the red, green and blue values match.
TypeInfo
Retrieves the BitmapPaletteType that describes the palette.
public BitmapPaletteType TypeInfo { get; }
Property Value
Remarks
WICBitmapPaletteCustom is used for palettes initialized from both InitializeCustom and InitializeFromBitmap. There is no distinction is made between optimized and custom palettes.
Methods
GetColors<T>()
Gets the colors.
public T[] GetColors<T>() where T : struct
Returns
- T[]
Type Parameters
T
HasAlpha(out RawBool)
Proxy function for the HasAlpha method.
public void HasAlpha(out RawBool fHasAlphaRef)
Parameters
fHasAlphaRef
RawBoolNo documentation.
Initialize(BitmapPaletteType, RawBool)
Initializes the palette to one of the pre-defined palettes specified by BitmapPaletteType and optionally adds a transparent color.
public void Initialize(BitmapPaletteType ePaletteType, RawBool fAddTransparentColor)
Parameters
ePaletteType
BitmapPaletteTypeNo documentation.
fAddTransparentColor
RawBoolNo documentation.
Remarks
If a transparent color is added to a palette, the palette is no longer predefined and is returned as WICBitmapPaletteTypeCustom. For palettes with less than 256 entries, the transparent entry is added to the end of the palette (that is, a 16-color palette becomes a 17-color palette). For palettes with 256 colors, the transparent palette entry will replace the last entry in the pre-defined palette.
Initialize(BitmapSource, int, RawBool)
Initializes a palette using a computed optimized values based on the reference bitmap.
public void Initialize(BitmapSource surfaceRef, int count, RawBool fAddTransparentColor)
Parameters
surfaceRef
BitmapSourcePointer to the source bitmap.
count
intThe number of colors to initialize the palette with.
fAddTransparentColor
RawBoolA value to indicate whether to add a transparent color.
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 fAddTransparentColor parameter to TRUE and one fewer optimized color will be computed, reducing the colorCount, and a fully transparent color entry will be added.
Initialize(Palette)
Initialize the palette based on a given palette.
public void Initialize(Palette paletteRef)
Parameters
paletteRef
PalettePointer to the source palette.
Initialize<T>(T[])
Initializes with the specified colors.
public void Initialize<T>(T[] colors) where T : struct
Parameters
colors
T[]The colors.
Type Parameters
T
Type of the color (must be 4 bytes, RGBA)
Exceptions
- ArgumentException
Color type must be 4 bytes
Operators
explicit operator Palette(nint)
public static explicit operator Palette(nint nativePtr)
Parameters
nativePtr
nint