Class InverseColorMap

java.lang.Object
com.twelvemonkeys.image.InverseColorMap

class InverseColorMap extends Object
Inverse Colormap to provide efficient lookup of any given input color to the closest match to the given color map.

Based on "Efficient Inverse Color Map Computation" by Spencer W. Thomas in "Graphics Gems Volume II".

Version:
$Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/image/InverseColorMap.java#1 $
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) byte[]
     
    (package private) int
     
    (package private) static final int
    Maximum value a quantised color channel can have
    (package private) int
     
    (package private) static final int
    Number of high bits of each color channel to use to lookup near match
    (package private) static final int
    BITMASK representing the bits for blue in the color lookup
    (package private) static final int
    BITMASK representing the bits for green in the color lookup
    (package private) static final int
    BITMASK representing the bits for red in the color lookup
    (package private) byte[]
     
    (package private) int[]
     
    (package private) int
     
    (package private) static final int
    Truncated bits of each color channel
  • Constructor Summary

    Constructors
    Constructor
    Description
    InverseColorMap(byte[] pRGBColorMap)
     
    InverseColorMap(byte[] pRGBColorMap, int pTransparent)
     
    InverseColorMap(int[] pRGBColorMap)
     
    InverseColorMap(int[] pRGBColorMap, int pTransparent)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final int
    getIndexNearest(int pColor)
    Gets the index of the nearest color to from the color map.
    final int
    getIndexNearest(int pRed, int pGreen, int pBlue)
    Gets the index of the nearest color to from the color map.
    (package private) void
    initIRGB(int[] pTemp)
    Simple inverse color table creation method.

    Methods inherited from class java.lang.Object

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

    • QUANTBITS

      static final int QUANTBITS
      Number of high bits of each color channel to use to lookup near match
      See Also:
    • TRUNCBITS

      static final int TRUNCBITS
      Truncated bits of each color channel
      See Also:
    • QUANTMASK_BLUE

      static final int QUANTMASK_BLUE
      BITMASK representing the bits for blue in the color lookup
      See Also:
    • QUANTMASK_GREEN

      static final int QUANTMASK_GREEN
      BITMASK representing the bits for green in the color lookup
      See Also:
    • QUANTMASK_RED

      static final int QUANTMASK_RED
      BITMASK representing the bits for red in the color lookup
      See Also:
    • MAXQUANTVAL

      static final int MAXQUANTVAL
      Maximum value a quantised color channel can have
      See Also:
    • rgbMapByte

      byte[] rgbMapByte
    • rgbMapInt

      int[] rgbMapInt
    • numColors

      int numColors
    • maxColor

      int maxColor
    • inverseRGB

      byte[] inverseRGB
    • transparentIndex

      int transparentIndex
  • Constructor Details

    • InverseColorMap

      InverseColorMap(byte[] pRGBColorMap)
      Parameters:
      pRGBColorMap - the rgb color map to create inverse color map for.
    • InverseColorMap

      InverseColorMap(int[] pRGBColorMap)
      Parameters:
      pRGBColorMap - the rgb color map to create inverse color map for.
    • InverseColorMap

      InverseColorMap(byte[] pRGBColorMap, int pTransparent)
      Parameters:
      pRGBColorMap - the rgb color map to create inverse color map for.
      pTransparent - the index of the transparent pixel in the map
    • InverseColorMap

      InverseColorMap(int[] pRGBColorMap, int pTransparent)
      Parameters:
      pRGBColorMap - the rgb color map to create inverse color map for.
      pTransparent - the index of the transparent pixel in the map
  • Method Details

    • initIRGB

      void initIRGB(int[] pTemp)
      Simple inverse color table creation method.
      Parameters:
      pTemp - temp array
    • getIndexNearest

      public final int getIndexNearest(int pColor)
      Gets the index of the nearest color to from the color map.
      Parameters:
      pColor - the color to get the nearest color to from color map color must be of format 0x00RRGGBB - standard default RGB
      Returns:
      index of color which closest matches input color by using the created inverse color map.
    • getIndexNearest

      public final int getIndexNearest(int pRed, int pGreen, int pBlue)
      Gets the index of the nearest color to from the color map.
      Parameters:
      pRed - red component of the color to get the nearest color to from color map
      pGreen - green component of the color to get the nearest color to from color map
      pBlue - blue component of the color to get the nearest color to from color map
      Returns:
      index of color which closest matches input color by using the created inverse color map.