ColorPalette

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.imaging.IColorPalette

public final class ColorPalette implements IColorPalette

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

Constructors

ConstructorDescription
ColorPalette(int[] argb32Entries, boolean isCompactPalette)Initializes a new instance of the ColorPalette class.
ColorPalette(int[] argb32Entries)Initializes a new instance of the ColorPalette class and IsCompactPalette is false.
ColorPalette(Color[] entries, boolean isCompactPalette)Initializes a new instance of the ColorPalette class.
ColorPalette(Color[] entries)Initializes a new instance of the ColorPalette class and IsCompactPalette is false.

Methods

MethodDescription
getEntriesCount()Gets the entries count.
getArgb32Entries()Gets an array of 32-bit ARGB structures.
getEntries()Gets an array of com.aspose.imaging.Color structures.
isCompactPalette()Gets or sets a value indicating whether compact palette is used.
copyPalette(IColorPalette colorPalette, boolean useCompactPalette)Copies the palette.
copyPalette(IColorPalette colorPalette)Copies the palette.
getNearestColorIndex(int argb32Color)Gets the index of the nearest color.
getNearestColorIndex(Color color)Gets the index of the nearest color.
getArgb32Color(int index)Gets the 32-bit ARGB palette color by index.
getColor(int index)Gets the palette color by index.

ColorPalette(int[] argb32Entries, boolean isCompactPalette)

public ColorPalette(int[] argb32Entries, boolean isCompactPalette)

Initializes a new instance of the ColorPalette class.

Parameters:

ParameterTypeDescription
argb32Entriesint[]The 32-bit ARGB color palette entries.
isCompactPalettebooleanIndicating whether compact it palette.

ColorPalette(int[] argb32Entries)

public ColorPalette(int[] argb32Entries)

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

Parameters:

ParameterTypeDescription
argb32Entriesint[]The 32-bit ARGB color palette entries.

ColorPalette(Color[] entries, boolean isCompactPalette)

public ColorPalette(Color[] entries, boolean isCompactPalette)

Initializes a new instance of the ColorPalette class.

Parameters:

ParameterTypeDescription
entriesColor[]The color palette entries.
isCompactPalettebooleanIndicating whether compact it palette.

ColorPalette(Color[] entries)

public ColorPalette(Color[] entries)

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

Parameters:

ParameterTypeDescription
entriesColor[]The color palette entries.

getEntriesCount()

public int getEntriesCount()

Gets the entries count.

Returns: int - The entries count.

getArgb32Entries()

public int[] getArgb32Entries()

Gets an array of 32-bit ARGB structures.

Returns: int[] - The entries. The copy of array of the 32-bit ARGB values that make up this ColorPalette.

getEntries()

public Color[] getEntries()

Gets an array of com.aspose.imaging.Color structures.

Returns: com.aspose.imaging.Color[] - The entries. The copy of array of the Color structures that make up this ColorPalette.

isCompactPalette()

public boolean isCompactPalette()

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

Returns: boolean - true if compact palette is used; otherwise, false.

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.

copyPalette(IColorPalette colorPalette, boolean useCompactPalette)

public static ColorPalette copyPalette(IColorPalette colorPalette, boolean useCompactPalette)

Copies the palette.

Parameters:

ParameterTypeDescription
colorPaletteIColorPaletteThe color palette.
useCompactPalettebooleanIndicating whether compact palette.

Returns: ColorPalette - The newly created and copied palette or null if null palette passed.

copyPalette(IColorPalette colorPalette)

public static ColorPalette copyPalette(IColorPalette colorPalette)

Copies the palette.

Parameters:

ParameterTypeDescription
colorPaletteIColorPaletteThe color palette.

Returns: ColorPalette - The newly created and copied palette or null if null palette passed.

getNearestColorIndex(int argb32Color)

public int getNearestColorIndex(int argb32Color)

Gets the index of the nearest color.

Parameters:

ParameterTypeDescription
argb32ColorintThe 32-bit ARGB color.

Returns: int - The index of the nearest color.

getNearestColorIndex(Color color)

public int getNearestColorIndex(Color color)

Gets the index of the nearest color.

Parameters:

ParameterTypeDescription
colorColorThe color.

Returns: int - The index of the nearest color.

getArgb32Color(int index)

public int getArgb32Color(int index)

Gets the 32-bit ARGB palette color by index.

Parameters:

ParameterTypeDescription
indexintThe 32-bit ARGB palette color index.

Returns: int - The color palette entry specified by the index.

getColor(int index)

public Color getColor(int index)

Gets the palette color by index.

Parameters:

ParameterTypeDescription
indexintThe palette color index.

Returns: Color - The color palette entry specified by the index.