Class ColorPalette

Class ColorPalette

Namespace: Aspose.Imaging
Assembly: Aspose.Imaging.dll (25.2.0)

Defines an array of colors that make up a color palette. The colors are 32-bit ARGB colors. Not inheritable.

[JsonObject(MemberSerialization.OptIn)]
public sealed class ColorPalette : IColorPalette

Inheritance

objectColorPalette

Implements

IColorPalette

Inherited Members

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

ColorPalette(int[], bool)

Initializes a new instance of the Aspose.Imaging.ColorPalette class.

[JsonConstructor]
public ColorPalette(int[] argb32Entries, bool isCompactPalette)

Parameters

argb32Entries int[]

The 32-bit ARGB color palette entries.

isCompactPalette bool

Indicating whether compact it palette.

ColorPalette(int[])

Initializes a new instance of the Aspose.Imaging.ColorPalette class and IsCompactPalette is false.

public ColorPalette(int[] argb32Entries)

Parameters

argb32Entries int[]

The 32-bit ARGB color palette entries.

ColorPalette(Color[], bool)

Initializes a new instance of the Aspose.Imaging.ColorPalette class.

public ColorPalette(Color[] entries, bool isCompactPalette)

Parameters

entries Color[]

The color palette entries.

isCompactPalette bool

Indicating whether compact it palette.

ColorPalette(Color[])

Initializes a new instance of the Aspose.Imaging.ColorPalette class and IsCompactPalette is false.

public ColorPalette(Color[] entries)

Parameters

entries Color[]

The color palette entries.

Properties

Argb32Entries

Gets an array of 32-bit ARGB structures.

public int[] Argb32Entries { get; }

Property Value

int[]

Entries

Gets an array of Aspose.Imaging.Color structures.

public Color[] Entries { get; }

Property Value

Color[]

EntriesCount

Gets the entries count.

public int EntriesCount { get; }

Property Value

int

IsCompactPalette

Gets or sets a value indicating whether compact palette is used.

public bool IsCompactPalette { get; }

Property Value

bool

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, bool)

Copies the palette.

public static ColorPalette CopyPalette(IColorPalette colorPalette, bool useCompactPalette)

Parameters

colorPalette IColorPalette

The color palette.

useCompactPalette bool

Indicating whether compact palette.

Returns

ColorPalette

The newly created and copied palette or null if null palette passed.

CopyPalette(IColorPalette)

Copies the palette.

public static ColorPalette CopyPalette(IColorPalette colorPalette)

Parameters

colorPalette IColorPalette

The color 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 int

The 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 int

The 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(int)

Gets the index of the nearest color.

public int GetNearestColorIndex(int argb32Color)

Parameters

argb32Color int

The 32-bit ARGB color.

Returns

int

The index of the nearest color.

GetNearestColorIndex(Color)

Gets the index of the nearest color.

public int GetNearestColorIndex(Color color)

Parameters

color Color

The color.

Returns

int

The index of the nearest color.