Class IconExe.PaletteData

  • Enclosing class:
    IconExe

    static class IconExe.PaletteData
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int blueMask
      the blue mask for a direct palette
      int blueShift
      the blue shift for a direct palette
      IconExe.RGB[] colors
      the RGB values for an indexed palette, where the indices of the array correspond to pixel values
      int greenMask
      the green mask for a direct palette
      int greenShift
      the green shift for a direct palette
      boolean isDirect
      true if the receiver is a direct palette, and false otherwise
      int redMask
      the red mask for a direct palette
      int redShift
      the red shift for a direct palette
    • Constructor Summary

      Constructors 
      Constructor Description
      PaletteData​(int redMask, int greenMask, int blueMask)
      Constructs a new direct palette given the red, green and blue masks.
      PaletteData​(IconExe.RGB[] colors)
      Constructs a new indexed palette given an array of RGB values.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getPixel​(IconExe.RGB rgb)
      Returns the pixel value corresponding to the given RBG.
      IconExe.RGB getRGB​(int pixel)
      Returns an RGB corresponding to the given pixel value.
      IconExe.RGB[] getRGBs()
      Returns all the RGB values in the receiver if it is an indexed palette, or null if it is a direct palette.
      (package private) int shiftForMask​(int mask)
      Computes the shift value for a given mask.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • isDirect

        public boolean isDirect
        true if the receiver is a direct palette, and false otherwise
      • colors

        public IconExe.RGB[] colors
        the RGB values for an indexed palette, where the indices of the array correspond to pixel values
      • redMask

        public int redMask
        the red mask for a direct palette
      • greenMask

        public int greenMask
        the green mask for a direct palette
      • blueMask

        public int blueMask
        the blue mask for a direct palette
      • redShift

        public int redShift
        the red shift for a direct palette
      • greenShift

        public int greenShift
        the green shift for a direct palette
      • blueShift

        public int blueShift
        the blue shift for a direct palette
    • Constructor Detail

      • PaletteData

        public PaletteData​(IconExe.RGB[] colors)
        Constructs a new indexed palette given an array of RGB values.
        Parameters:
        colors - the array of RGBs for the palette
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the argument is null
      • PaletteData

        public PaletteData​(int redMask,
                           int greenMask,
                           int blueMask)
        Constructs a new direct palette given the red, green and blue masks.
        Parameters:
        redMask - the red mask
        greenMask - the green mask
        blueMask - the blue mask
    • Method Detail

      • getPixel

        public int getPixel​(IconExe.RGB rgb)
        Returns the pixel value corresponding to the given RBG.
        Parameters:
        rgb - the RGB to get the pixel value for
        Returns:
        the pixel value for the given RGB
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the argument is null
        • ERROR_INVALID_ARGUMENT - if the RGB is not found in the palette
      • getRGB

        public IconExe.RGB getRGB​(int pixel)
        Returns an RGB corresponding to the given pixel value.
        Parameters:
        pixel - the pixel to get the RGB value for
        Returns:
        the RGB value for the given pixel
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the argument is null
        • ERROR_INVALID_ARGUMENT - if the pixel does not exist in the palette
      • getRGBs

        public IconExe.RGB[] getRGBs()
        Returns all the RGB values in the receiver if it is an indexed palette, or null if it is a direct palette.
        Returns:
        the RGBs for the receiver or null
      • shiftForMask

        int shiftForMask​(int mask)
        Computes the shift value for a given mask.
        Parameters:
        mask - the mask to compute the shift for
        Returns:
        the shift amount
        See Also:
        IconExe.PaletteData