Packages

 

com.aspose.cad

Class ColorPalette

  • All Implemented Interfaces:
    IColorPalette


    public final class ColorPalette
    extends Object
    implements IColorPalette

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

    • Constructor Detail

      • ColorPalette

        public ColorPalette(int[] argb32Entries,
                            boolean isCompactPalette)

        Initializes a new instance of the ColorPalette class.

        Parameters:
        argb32Entries - The 32-bit ARGB color palette entries.
        isCompactPalette - Indicating whether compact it palette.
      • ColorPalette

        public ColorPalette(int[] argb32Entries)

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

        Parameters:
        argb32Entries - The 32-bit ARGB color palette entries.
      • ColorPalette

        public ColorPalette(Color[] entries,
                            boolean isCompactPalette)

        Initializes a new instance of the ColorPalette class.

        Parameters:
        entries - The color palette entries.
        isCompactPalette - Indicating whether compact it palette.
      • ColorPalette

        public ColorPalette(Color[] entries)

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

        Parameters:
        entries - The color palette entries.
    • Method Detail

      • getEntriesCount

        public int getEntriesCount()

        Gets the entries count.

        Value: The entries count.
        Specified by:
        getEntriesCount in interface IColorPalette
        Returns:
        The entries count.
      • getArgb32Entries

        public int[] getArgb32Entries()

        Gets an array of 32-bit ARGB structures.

        Specified by:
        getArgb32Entries in interface IColorPalette
        Returns:
        The array of 32-bit ARGB structure that make up this Aspose.Imaging.ColorPalette. Value: The entries.
      • getEntries

        public Color[] getEntries()

        Gets an array of Aspose.Imaging.Color structures.

        Specified by:
        getEntries in interface IColorPalette
        Returns:
        The array of Aspose.Imaging.Color structure that make up this Aspose.Imaging.ColorPalette. Value: The entries.
      • isCompactPalette

        public boolean isCompactPalette()

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

        Value: 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.

        Specified by:
        isCompactPalette in interface IColorPalette
      • copyPalette

        public static ColorPalette copyPalette(IColorPalette colorPalette,
                                               boolean useCompactPalette)

        Copies the palette.

        Parameters:
        colorPalette - The color palette.
        useCompactPalette - Indicating whether compact palette.
        Returns:
        The newly created and copied palette or null if null palette passed.
      • copyPalette

        public static ColorPalette copyPalette(IColorPalette colorPalette)

        Copies the palette.

        Parameters:
        colorPalette - The color palette.
        Returns:
        The newly created and copied palette or null if null palette passed.
      • getNearestColorIndex

        public int getNearestColorIndex(int argb32Color)

        Gets the index of the nearest color.

        Specified by:
        getNearestColorIndex in interface IColorPalette
        Parameters:
        argb32Color - The 32-bit ARGB color.
        Returns:
        The index of the nearest color.
      • getNearestColorIndex

        public int getNearestColorIndex(Color color)

        Gets the index of the nearest color.

        Specified by:
        getNearestColorIndex in interface IColorPalette
        Parameters:
        color - The color.
        Returns:
        The index of the nearest color.
      • getArgb32Color

        public int getArgb32Color(int index)

        Gets the 32-bit ARGB palette color by index.

        Specified by:
        getArgb32Color in interface IColorPalette
        Parameters:
        index - The 32-bit ARGB palette color index.
        Returns:
        The color palette entry specified by the index.
        Throws:
        com.aspose.ms.System.ArgumentOutOfRangeException - if color palette index specified is out of the palette entries range.
      • getColor

        public Color getColor(int index)

        Gets the palette color by index.

        Specified by:
        getColor in interface IColorPalette
        Parameters:
        index - The palette color index.
        Returns:
        The color palette entry specified by the index.
        Throws:
        com.aspose.ms.System.ArgumentOutOfRangeException - if color palette index specified is out of the palette entries range.