Package com.twelvemonkeys.image
Class InverseColorMap
- java.lang.Object
-
- com.twelvemonkeys.image.InverseColorMap
-
class InverseColorMap extends java.lang.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[]
inverseRGB
(package private) int
maxColor
(package private) static int
MAXQUANTVAL
Maximum value a quantised color channel can have(package private) int
numColors
(package private) static int
QUANTBITS
Number of high bits of each color channel to use to lookup near match(package private) static int
QUANTMASK_BLUE
BITMASK representing the bits for blue in the color lookup(package private) static int
QUANTMASK_GREEN
BITMASK representing the bits for green in the color lookup(package private) static int
QUANTMASK_RED
BITMASK representing the bits for red in the color lookup(package private) byte[]
rgbMapByte
(package private) int[]
rgbMapInt
(package private) int
transparentIndex
(package private) static int
TRUNCBITS
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getIndexNearest(int pColor)
Gets the index of the nearest color to from the color map.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.
-
-
-
Field Detail
-
QUANTBITS
static final int QUANTBITS
Number of high bits of each color channel to use to lookup near match- See Also:
- Constant Field Values
-
TRUNCBITS
static final int TRUNCBITS
Truncated bits of each color channel- See Also:
- Constant Field Values
-
QUANTMASK_BLUE
static final int QUANTMASK_BLUE
BITMASK representing the bits for blue in the color lookup- See Also:
- Constant Field Values
-
QUANTMASK_GREEN
static final int QUANTMASK_GREEN
BITMASK representing the bits for green in the color lookup- See Also:
- Constant Field Values
-
QUANTMASK_RED
static final int QUANTMASK_RED
BITMASK representing the bits for red in the color lookup- See Also:
- Constant Field Values
-
MAXQUANTVAL
static final int MAXQUANTVAL
Maximum value a quantised color channel can have- See Also:
- Constant Field Values
-
rgbMapByte
byte[] rgbMapByte
-
rgbMapInt
int[] rgbMapInt
-
numColors
int numColors
-
maxColor
int maxColor
-
inverseRGB
byte[] inverseRGB
-
transparentIndex
int transparentIndex
-
-
Constructor Detail
-
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 Detail
-
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 format0x00RRGGBB
- 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 mappGreen
- green component of the color to get the nearest color to from color mappBlue
- 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.
-
-