Package com.twelvemonkeys.image
Class InverseColorMapIndexColorModel
java.lang.Object
java.awt.image.ColorModel
java.awt.image.IndexColorModel
com.twelvemonkeys.image.InverseColorMapIndexColorModel
- All Implemented Interfaces:
Transparency
A faster implementation of
IndexColorModel
, that is backed by an
inverse color-map, for fast look-ups.- Version:
- $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/image/InverseColorMapIndexColorModel.java#1 $
- Author:
- Harald Kuhr, $Author: haku $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.twelvemonkeys.image.InverseColorMap
protected int
protected int[]
Fields inherited from class java.awt.image.ColorModel
pixel_bits, transferType
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
-
Constructor Summary
ConstructorsConstructorDescriptionInverseColorMapIndexColorModel
(int pNumBits, int pSize, byte[] pReds, byte[] pGreens, byte[] pBlues) Creates anInverseColorMapIndexColorModel
from the given arrays of red, green, and blue components.InverseColorMapIndexColorModel
(int pNumBits, int pSize, byte[] pReds, byte[] pGreens, byte[] pBlues, int pTransparentIndex) Creates anInverseColorMapIndexColorModel
from the given arrays of red, green, and blue components, plus one transparent index.InverseColorMapIndexColorModel
(int pNumBits, int pSize, int[] pRGBs, int pStart, boolean pAlpha, int pTransparentIndex, int pTransferType) Creates anInverseColorMapIndexColorModel
from the given array of RGB components, plus one transparent index.InverseColorMapIndexColorModel
(IndexColorModel pColorModel) Creates anInverseColorMapIndexColorModel
from an existingIndexColorModel
. -
Method Summary
Modifier and TypeMethodDescriptionstatic IndexColorModel
Creates anIndexColorModel
optimized for the givenImage
.getDataElements
(int rgb, Object pixel) Returns a data element array representation of a pixel in this ColorModel, given an integer pixel representation in the default RGB color model.toString()
Methods inherited from class java.awt.image.IndexColorModel
convertToIntDiscrete, createCompatibleSampleModel, createCompatibleWritableRaster, equals, finalize, getAlpha, getAlphas, getBlue, getBlues, getComponents, getComponents, getComponentSize, getDataElement, getDataElements, getGreen, getGreens, getMapSize, getRed, getReds, getRGB, getRGBs, getTransparency, getTransparentPixel, getValidPixels, hashCode, isCompatibleRaster, isCompatibleSampleModel, isValid, isValid
Methods inherited from class java.awt.image.ColorModel
coerceData, getAlpha, getAlphaRaster, getBlue, getColorSpace, getComponentSize, getDataElement, getDataElements, getGreen, getNormalizedComponents, getNormalizedComponents, getNumColorComponents, getNumComponents, getPixelSize, getRed, getRGB, getRGBdefault, getTransferType, getUnnormalizedComponents, hasAlpha, isAlphaPremultiplied
-
Field Details
-
rgbs
protected int[] rgbs -
mapSize
protected int mapSize -
inverseMap
protected com.twelvemonkeys.image.InverseColorMap inverseMap
-
-
Constructor Details
-
InverseColorMapIndexColorModel
Creates anInverseColorMapIndexColorModel
from an existingIndexColorModel
.- Parameters:
pColorModel
- the color model to create from.- Throws:
IllegalArgumentException
- ifpColorModel
isnull
-
InverseColorMapIndexColorModel
public InverseColorMapIndexColorModel(int pNumBits, int pSize, int[] pRGBs, int pStart, boolean pAlpha, int pTransparentIndex, int pTransferType) Creates anInverseColorMapIndexColorModel
from the given array of RGB components, plus one transparent index.- Parameters:
pNumBits
- the number of bits each pixel occupiespSize
- the size of the color component arrayspRGBs
- the array of packed RGB color componentspStart
- the starting offset of the first color componentpAlpha
- indicates whether alpha values are contained inpRGBs
pTransparentIndex
- the index of the transparent pixelpTransferType
- the data type of the array used to represent pixels- Throws:
IllegalArgumentException
- if bits is less than 1 or greater than 16, or if size is less than 1- See Also:
-
InverseColorMapIndexColorModel
public InverseColorMapIndexColorModel(int pNumBits, int pSize, byte[] pReds, byte[] pGreens, byte[] pBlues, int pTransparentIndex) Creates anInverseColorMapIndexColorModel
from the given arrays of red, green, and blue components, plus one transparent index.- Parameters:
pNumBits
- the number of bits each pixel occupiespSize
- the size of the color component arrayspReds
- the array of red color componentspGreens
- the array of green color componentspBlues
- the array of blue color componentspTransparentIndex
- the index of the transparent pixel- Throws:
IllegalArgumentException
- if bits is less than 1 or greater than 16, or if size is less than 1- See Also:
-
InverseColorMapIndexColorModel
public InverseColorMapIndexColorModel(int pNumBits, int pSize, byte[] pReds, byte[] pGreens, byte[] pBlues) Creates anInverseColorMapIndexColorModel
from the given arrays of red, green, and blue components.- Parameters:
pNumBits
- the number of bits each pixel occupiespSize
- the size of the color component arrayspReds
- the array of red color componentspGreens
- the array of green color componentspBlues
- the array of blue color components- Throws:
IllegalArgumentException
- if bits is less than 1 or greater than 16, or if size is less than 1- See Also:
-
-
Method Details
-
create
Creates anIndexColorModel
optimized for the givenImage
.- Parameters:
pImage
- theImage
containing the RGB samplespNumCols
- the maximum number of colors in theIndexColorModel
pFlags
- flags- Returns:
- a new optimized
IndexColorModel
-
getDataElements
Returns a data element array representation of a pixel in this ColorModel, given an integer pixel representation in the default RGB color model. This array can then be passed to thesetDataElements
method of aWritableRaster
object. If the pixel variable isnull
, a new array is allocated. Ifpixel
is notnull
, it must be a primitive array of typetransferType
; otherwise, aClassCastException
is thrown. AnArrayIndexOutOfBoundsException
is thrown ifpixel
is not large enough to hold a pixel value for thisColorModel
. The pixel array is returned.Since
OpaqueIndexColorModel
can be subclassed, subclasses inherit the implementation of this method and if they don't override it then they throw an exception if they use an unsupportedtransferType
. #param rgb the integer pixel representation in the default RGB color model #param pixel the specified pixel #return an array representation of the specified pixel in thisOpaqueIndexColorModel
. #throws ClassCastException ifpixel
is not a primitive array of typetransferType
#throws ArrayIndexOutOfBoundsException ifpixel
is not large enough to hold a pixel value for thisColorModel
#throws UnsupportedOperationException iftransferType
is invalid -
toString
- Overrides:
toString
in classIndexColorModel
-