Class ColorPalette
Defines an array of colors that make up a color palette. The colors are 32-bit ARGB colors. Not inheritable.
public sealed class ColorPalette : IColorPalette
- Inheritance
-
ColorPalette
- Implements
- Inherited Members
Constructors
ColorPalette(Color[])
Initializes a new instance of the ColorPalette class and IsCompactPalette is false.
public ColorPalette(Color[] entries)
Parameters
entries
Color[]The color palette entries.
ColorPalette(Color[], bool)
Initializes a new instance of the ColorPalette class.
public ColorPalette(Color[] entries, bool isCompactPalette)
Parameters
entries
Color[]The color palette entries.
isCompactPalette
boolIndicating whether compact it palette.
ColorPalette(int[])
Initializes a new instance of the ColorPalette class and IsCompactPalette is false.
public ColorPalette(int[] argb32Entries)
Parameters
argb32Entries
int[]The 32-bit ARGB color palette entries.
ColorPalette(int[], bool)
Initializes a new instance of the ColorPalette class.
public ColorPalette(int[] argb32Entries, bool isCompactPalette)
Parameters
argb32Entries
int[]The 32-bit ARGB color palette entries.
isCompactPalette
boolIndicating whether compact it palette.
Properties
Argb32Entries
Gets an array of 32-bit ARGB structures.
public int[] Argb32Entries { get; }
Property Value
- int[]
The entries.
Entries
Gets an array of Color structures.
public Color[] Entries { get; }
Property Value
- Color[]
The entries.
EntriesCount
Gets the entries count.
public int EntriesCount { get; }
Property Value
- int
The entries count.
IsCompactPalette
Gets or sets a value indicating whether compact palette is used.
public bool IsCompactPalette { get; }
Property Value
- bool
true
if compact palette is used; otherwise,false
.
Remarks
Compact palette means that image will contain only the specified palette entries if possible or in other words the image will be more compact and occupy less space; otherwise there will be 2^BitsPerPixel entries and image will reserve more space for all possible palette entries. Setting this value to true and changing palette entries may cause performance penalty since data movement may occur so use it carefully.
Methods
CopyPalette(IColorPalette)
Copies the palette.
public static ColorPalette CopyPalette(IColorPalette colorPalette)
Parameters
colorPalette
IColorPaletteThe color palette.
Returns
- ColorPalette
The newly created and copied palette or null if null palette passed.
CopyPalette(IColorPalette, bool)
Copies the palette.
public static ColorPalette CopyPalette(IColorPalette colorPalette, bool useCompactPalette)
Parameters
colorPalette
IColorPaletteThe color palette.
useCompactPalette
boolIndicating whether compact palette.
Returns
- ColorPalette
The newly created and copied palette or null if null palette passed.
GetArgb32Color(int)
Gets the 32-bit ARGB palette color by index.
public int GetArgb32Color(int index)
Parameters
index
intThe 32-bit ARGB palette color index.
Returns
- int
The color palette entry specified by the
index
.
Exceptions
- ArgumentOutOfRangeException
if color palette
index
specified is out of the palette entries range.
GetColor(int)
Gets the palette color by index.
public Color GetColor(int index)
Parameters
index
intThe palette color index.
Returns
- Color
The color palette entry specified by the
index
.
Exceptions
- ArgumentOutOfRangeException
if color palette
index
specified is out of the palette entries range.
GetNearestColorIndex(Color)
Gets the index of the nearest color.
public int GetNearestColorIndex(Color color)
Parameters
color
ColorThe color.
Returns
- int
The index of the nearest color.
GetNearestColorIndex(int)
Gets the index of the nearest color.
public int GetNearestColorIndex(int argb32Color)
Parameters
argb32Color
intThe 32-bit ARGB color.
Returns
- int
The index of the nearest color.