Package com.twelvemonkeys.image
Class InverseColorMap
java.lang.Object
com.twelvemonkeys.image.InverseColorMap
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
FieldsModifier and TypeFieldDescription(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
ConstructorsConstructorDescriptionInverseColorMap
(byte[] pRGBColorMap) InverseColorMap
(byte[] pRGBColorMap, int pTransparent) InverseColorMap
(int[] pRGBColorMap) InverseColorMap
(int[] pRGBColorMap, int pTransparent) -
Method Summary
Modifier and TypeMethodDescriptionfinal 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.
-
Field Details
-
QUANTBITS
static final int QUANTBITSNumber of high bits of each color channel to use to lookup near match- See Also:
-
TRUNCBITS
static final int TRUNCBITSTruncated bits of each color channel- See Also:
-
QUANTMASK_BLUE
static final int QUANTMASK_BLUEBITMASK representing the bits for blue in the color lookup- See Also:
-
QUANTMASK_GREEN
static final int QUANTMASK_GREENBITMASK representing the bits for green in the color lookup- See Also:
-
QUANTMASK_RED
static final int QUANTMASK_REDBITMASK representing the bits for red in the color lookup- See Also:
-
MAXQUANTVAL
static final int MAXQUANTVALMaximum 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 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.
-