java.awt.image
Class IndexColorModel

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.awt.image.ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel 
      extended by java.awt.image.IndexColorModel
All Implemented Interfaces:
Transparency sample code for java.awt.Transparency definition code for java.awt.Transparency

public class IndexColorModel
extends ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel

The IndexColorModel class is a ColorModel class that works with pixel values consisting of a single sample that is an index into a fixed colormap in the default sRGB color space. The colormap specifies red, green, blue, and optional alpha components corresponding to each index. All components are represented in the colormap as 8-bit unsigned integral values. Some constructors allow the caller to specify "holes" in the colormap by indicating which colormap entries are valid and which represent unusable colors via the bits set in a BigInteger object. This color model is similar to an X11 PseudoColor visual.

Some constructors provide a means to specify an alpha component for each pixel in the colormap, while others either provide no such means or, in some cases, a flag to indicate whether the colormap data contains alpha values. If no alpha is supplied to the constructor, an opaque alpha component (alpha = 1.0) is assumed for each entry. An optional transparent pixel value can be supplied that indicates a pixel to be made completely transparent, regardless of any alpha component supplied or assumed for that pixel value. Note that the color components in the colormap of an IndexColorModel objects are never pre-multiplied with the alpha components.

The transparency of an IndexColorModel object is determined by examining the alpha components of the colors in the colormap and choosing the most specific value after considering the optional alpha values and any transparent index specified. The transparency value is Transparency.OPAQUE only if all valid colors in the colormap are opaque and there is no valid transparent pixel. If all valid colors in the colormap are either completely opaque (alpha = 1.0) or completely transparent (alpha = 0.0), which typically occurs when a valid transparent pixel is specified, the value is Transparency.BITMASK. Otherwise, the value is Transparency.TRANSLUCENT, indicating that some valid color has an alpha component that is neither completely transparent nor completely opaque (0.0 < alpha < 1.0).

If an IndexColorModel object has a transparency value of Transparency.OPAQUE, then the hasAlpha and getNumComponents methods (both inherited from ColorModel) return false and 3, respectively. For any other transparency value, hasAlpha returns true and getNumComponents returns 4.

The index represented by a pixel value is stored in the least significant n bits of the pixel representations passed to the methods of this class, where n is the pixel size specified to the constructor for a particular IndexColorModel object; n must be between 1 and 16, inclusive. Higher order bits in pixel representations are assumed to be zero. For those methods that use a primitive array pixel representation of type transferType, the array length is always one. The transfer types supported are DataBuffer.TYPE_BYTE and DataBuffer.TYPE_USHORT. A single int pixel representation is valid for all objects of this class, since it is always possible to represent pixel values used with this class in a single int. Therefore, methods that use this representation do not throw an IllegalArgumentException due to an invalid pixel value.

Many of the methods in this class are final. The reason for this is that the underlying native graphics code makes assumptions about the layout and operation of this class and those assumptions are reflected in the implementations of the methods here that are marked final. You can subclass this class for other reasons, but you cannot override or modify the behaviour of those methods.

See Also:
ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel , ColorSpace sample code for java.awt.color.ColorSpace definition code for java.awt.color.ColorSpace , DataBuffer sample code for java.awt.image.DataBuffer definition code for java.awt.image.DataBuffer

Field Summary
 
Fields inherited from class java.awt.image.ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel
pixel_bits, transferType sample code for java.awt.image.ColorModel.transferType definition code for java.awt.image.ColorModel.transferType
 
Fields inherited from interface java.awt.Transparency sample code for java.awt.Transparency definition code for java.awt.Transparency
BITMASK sample code for java.awt.Transparency.BITMASK definition code for java.awt.Transparency.BITMASK , OPAQUE sample code for java.awt.Transparency.OPAQUE definition code for java.awt.Transparency.OPAQUE , TRANSLUCENT sample code for java.awt.Transparency.TRANSLUCENT definition code for java.awt.Transparency.TRANSLUCENT
 
Constructor Summary
IndexColorModel sample code for java.awt.image.IndexColorModel.IndexColorModel(int, int, byte[], byte[], byte[]) definition code for java.awt.image.IndexColorModel.IndexColorModel(int, int, byte[], byte[], byte[]) (int bits, int size, byte[] r, byte[] g, byte[] b)
          Constructs an IndexColorModel from the specified arrays of red, green, and blue components.
IndexColorModel sample code for java.awt.image.IndexColorModel.IndexColorModel(int, int, byte[], byte[], byte[], byte[]) definition code for java.awt.image.IndexColorModel.IndexColorModel(int, int, byte[], byte[], byte[], byte[]) (int bits, int size, byte[] r, byte[] g, byte[] b, byte[] a)
          Constructs an IndexColorModel from the given arrays of red, green, blue and alpha components.
IndexColorModel sample code for java.awt.image.IndexColorModel.IndexColorModel(int, int, byte[], byte[], byte[], int) definition code for java.awt.image.IndexColorModel.IndexColorModel(int, int, byte[], byte[], byte[], int) (int bits, int size, byte[] r, byte[] g, byte[] b, int trans)
          Constructs an IndexColorModel from the given arrays of red, green, and blue components.
IndexColorModel sample code for java.awt.image.IndexColorModel.IndexColorModel(int, int, byte[], int, boolean) definition code for java.awt.image.IndexColorModel.IndexColorModel(int, int, byte[], int, boolean) (int bits, int size, byte[] cmap, int start, boolean hasalpha)
          Constructs an IndexColorModel from a single array of interleaved red, green, blue and optional alpha components.
IndexColorModel sample code for java.awt.image.IndexColorModel.IndexColorModel(int, int, byte[], int, boolean, int) definition code for java.awt.image.IndexColorModel.IndexColorModel(int, int, byte[], int, boolean, int) (int bits, int size, byte[] cmap, int start, boolean hasalpha, int trans)
          Constructs an IndexColorModel from a single array of interleaved red, green, blue and optional alpha components.
IndexColorModel sample code for java.awt.image.IndexColorModel.IndexColorModel(int, int, int[], int, boolean, int, int) definition code for java.awt.image.IndexColorModel.IndexColorModel(int, int, int[], int, boolean, int, int) (int bits, int size, int[] cmap, int start, boolean hasalpha, int trans, int transferType)
          Constructs an IndexColorModel from an array of ints where each int is comprised of red, green, blue, and optional alpha components in the default RGB color model format.
IndexColorModel sample code for java.awt.image.IndexColorModel.IndexColorModel(int, int, int[], int, int, java.math.BigInteger) definition code for java.awt.image.IndexColorModel.IndexColorModel(int, int, int[], int, int, java.math.BigInteger) (int bits, int size, int[] cmap, int start, int transferType, BigInteger sample code for java.math.BigInteger definition code for java.math.BigInteger  validBits)
          Constructs an IndexColorModel from an int array where each int is comprised of red, green, blue, and alpha components in the default RGB color model format.
 
Method Summary
 BufferedImage sample code for java.awt.image.BufferedImage definition code for java.awt.image.BufferedImage convertToIntDiscrete sample code for java.awt.image.IndexColorModel.convertToIntDiscrete(java.awt.image.Raster, boolean) definition code for java.awt.image.IndexColorModel.convertToIntDiscrete(java.awt.image.Raster, boolean) (Raster sample code for java.awt.image.Raster definition code for java.awt.image.Raster  raster, boolean forceARGB)
          Returns a new BufferedImage of TYPE_INT_ARGB or TYPE_INT_RGB that has a Raster with pixel data computed by expanding the indices in the source Raster using the color/alpha component arrays of this ColorModel.
 SampleModel sample code for java.awt.image.SampleModel definition code for java.awt.image.SampleModel createCompatibleSampleModel sample code for java.awt.image.IndexColorModel.createCompatibleSampleModel(int, int) definition code for java.awt.image.IndexColorModel.createCompatibleSampleModel(int, int) (int w, int h)
          Creates a SampleModel with the specified width and height that has a data layout compatible with this ColorModel.
 WritableRaster sample code for java.awt.image.WritableRaster definition code for java.awt.image.WritableRaster createCompatibleWritableRaster sample code for java.awt.image.IndexColorModel.createCompatibleWritableRaster(int, int) definition code for java.awt.image.IndexColorModel.createCompatibleWritableRaster(int, int) (int w, int h)
          Creates a WritableRaster with the specified width and height that has a data layout (SampleModel) compatible with this ColorModel.
 void finalize sample code for java.awt.image.IndexColorModel.finalize() definition code for java.awt.image.IndexColorModel.finalize() ()
          Disposes of system resources associated with this ColorModel once this ColorModel is no longer referenced.
 int getAlpha sample code for java.awt.image.IndexColorModel.getAlpha(int) definition code for java.awt.image.IndexColorModel.getAlpha(int) (int pixel)
          Returns the alpha component for the specified pixel, scaled from 0 to 255.
 void getAlphas sample code for java.awt.image.IndexColorModel.getAlphas(byte[]) definition code for java.awt.image.IndexColorModel.getAlphas(byte[]) (byte[] a)
          Copies the array of alpha transparency components into the specified array.
 int getBlue sample code for java.awt.image.IndexColorModel.getBlue(int) definition code for java.awt.image.IndexColorModel.getBlue(int) (int pixel)
          Returns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB.
 void getBlues sample code for java.awt.image.IndexColorModel.getBlues(byte[]) definition code for java.awt.image.IndexColorModel.getBlues(byte[]) (byte[] b)
          Copies the array of blue color components into the specified array.
 int[] getComponents sample code for java.awt.image.IndexColorModel.getComponents(int, int[], int) definition code for java.awt.image.IndexColorModel.getComponents(int, int[], int) (int pixel, int[] components, int offset)
          Returns an array of unnormalized color/alpha components for a specified pixel in this ColorModel.
 int[] getComponents sample code for java.awt.image.IndexColorModel.getComponents(java.lang.Object, int[], int) definition code for java.awt.image.IndexColorModel.getComponents(java.lang.Object, int[], int) (Object sample code for java.lang.Object definition code for java.lang.Object  pixel, int[] components, int offset)
          Returns an array of unnormalized color/alpha components for a specified pixel in this ColorModel.
 int[] getComponentSize sample code for java.awt.image.IndexColorModel.getComponentSize() definition code for java.awt.image.IndexColorModel.getComponentSize() ()
          Returns an array of the number of bits for each color/alpha component.
 int getDataElement sample code for java.awt.image.IndexColorModel.getDataElement(int[], int) definition code for java.awt.image.IndexColorModel.getDataElement(int[], int) (int[] components, int offset)
          Returns a pixel value represented as an int in this ColorModel given an array of unnormalized color/alpha components.
 Object sample code for java.lang.Object definition code for java.lang.Object getDataElements sample code for java.awt.image.IndexColorModel.getDataElements(int[], int, java.lang.Object) definition code for java.awt.image.IndexColorModel.getDataElements(int[], int, java.lang.Object) (int[] components, int offset, Object sample code for java.lang.Object definition code for java.lang.Object  pixel)
          Returns a data element array representation of a pixel in this ColorModel given an array of unnormalized color/alpha components.
 Object sample code for java.lang.Object definition code for java.lang.Object getDataElements sample code for java.awt.image.IndexColorModel.getDataElements(int, java.lang.Object) definition code for java.awt.image.IndexColorModel.getDataElements(int, java.lang.Object) (int rgb, Object sample code for java.lang.Object definition code for java.lang.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.
 int getGreen sample code for java.awt.image.IndexColorModel.getGreen(int) definition code for java.awt.image.IndexColorModel.getGreen(int) (int pixel)
          Returns the green color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB.
 void getGreens sample code for java.awt.image.IndexColorModel.getGreens(byte[]) definition code for java.awt.image.IndexColorModel.getGreens(byte[]) (byte[] g)
          Copies the array of green color components into the specified array.
 int getMapSize sample code for java.awt.image.IndexColorModel.getMapSize() definition code for java.awt.image.IndexColorModel.getMapSize() ()
          Returns the size of the color/alpha component arrays in this IndexColorModel.
 int getRed sample code for java.awt.image.IndexColorModel.getRed(int) definition code for java.awt.image.IndexColorModel.getRed(int) (int pixel)
          Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB.
 void getReds sample code for java.awt.image.IndexColorModel.getReds(byte[]) definition code for java.awt.image.IndexColorModel.getReds(byte[]) (byte[] r)
          Copies the array of red color components into the specified array.
 int getRGB sample code for java.awt.image.IndexColorModel.getRGB(int) definition code for java.awt.image.IndexColorModel.getRGB(int) (int pixel)
          Returns the color/alpha components of the pixel in the default RGB color model format.
 void getRGBs sample code for java.awt.image.IndexColorModel.getRGBs(int[]) definition code for java.awt.image.IndexColorModel.getRGBs(int[]) (int[] rgb)
          Converts data for each index from the color and alpha component arrays to an int in the default RGB ColorModel format and copies the resulting 32-bit ARGB values into the specified array.
 int getTransparency sample code for java.awt.image.IndexColorModel.getTransparency() definition code for java.awt.image.IndexColorModel.getTransparency() ()
          Returns the transparency.
 int getTransparentPixel sample code for java.awt.image.IndexColorModel.getTransparentPixel() definition code for java.awt.image.IndexColorModel.getTransparentPixel() ()
          Returns the index of a transparent pixel in this IndexColorModel or -1 if there is no pixel with an alpha value of 0.
 BigInteger sample code for java.math.BigInteger definition code for java.math.BigInteger getValidPixels sample code for java.awt.image.IndexColorModel.getValidPixels() definition code for java.awt.image.IndexColorModel.getValidPixels() ()
          Returns a BigInteger that indicates the valid/invalid pixels in the colormap.
 boolean isCompatibleRaster sample code for java.awt.image.IndexColorModel.isCompatibleRaster(java.awt.image.Raster) definition code for java.awt.image.IndexColorModel.isCompatibleRaster(java.awt.image.Raster) (Raster sample code for java.awt.image.Raster definition code for java.awt.image.Raster  raster)
          Returns true if raster is compatible with this ColorModel or false if it is not compatible with this ColorModel.
 boolean isCompatibleSampleModel sample code for java.awt.image.IndexColorModel.isCompatibleSampleModel(java.awt.image.SampleModel) definition code for java.awt.image.IndexColorModel.isCompatibleSampleModel(java.awt.image.SampleModel) (SampleModel sample code for java.awt.image.SampleModel definition code for java.awt.image.SampleModel  sm)
          Checks if the specified SampleModel is compatible with this ColorModel.
 boolean isValid sample code for java.awt.image.IndexColorModel.isValid() definition code for java.awt.image.IndexColorModel.isValid() ()
          Returns whether or not all of the pixels are valid.
 boolean isValid sample code for java.awt.image.IndexColorModel.isValid(int) definition code for java.awt.image.IndexColorModel.isValid(int) (int pixel)
          Returns whether or not the pixel is valid.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for java.awt.image.IndexColorModel.toString() definition code for java.awt.image.IndexColorModel.toString() ()
          Returns the String representation of the contents of this ColorModelobject.
 
Methods inherited from class java.awt.image.ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel
coerceData sample code for java.awt.image.ColorModel.coerceData(java.awt.image.WritableRaster, boolean) definition code for java.awt.image.ColorModel.coerceData(java.awt.image.WritableRaster, boolean) , equals sample code for java.awt.image.ColorModel.equals(java.lang.Object) definition code for java.awt.image.ColorModel.equals(java.lang.Object) , getAlpha sample code for java.awt.image.ColorModel.getAlpha(java.lang.Object) definition code for java.awt.image.ColorModel.getAlpha(java.lang.Object) , getAlphaRaster sample code for java.awt.image.ColorModel.getAlphaRaster(java.awt.image.WritableRaster) definition code for java.awt.image.ColorModel.getAlphaRaster(java.awt.image.WritableRaster) , getBlue sample code for java.awt.image.ColorModel.getBlue(java.lang.Object) definition code for java.awt.image.ColorModel.getBlue(java.lang.Object) , getColorSpace sample code for java.awt.image.ColorModel.getColorSpace() definition code for java.awt.image.ColorModel.getColorSpace() , getComponentSize sample code for java.awt.image.ColorModel.getComponentSize(int) definition code for java.awt.image.ColorModel.getComponentSize(int) , getDataElement sample code for java.awt.image.ColorModel.getDataElement(float[], int) definition code for java.awt.image.ColorModel.getDataElement(float[], int) , getDataElements sample code for java.awt.image.ColorModel.getDataElements(float[], int, java.lang.Object) definition code for java.awt.image.ColorModel.getDataElements(float[], int, java.lang.Object) , getGreen sample code for java.awt.image.ColorModel.getGreen(java.lang.Object) definition code for java.awt.image.ColorModel.getGreen(java.lang.Object) , getNormalizedComponents sample code for java.awt.image.ColorModel.getNormalizedComponents(int[], int, float[], int) definition code for java.awt.image.ColorModel.getNormalizedComponents(int[], int, float[], int) , getNormalizedComponents sample code for java.awt.image.ColorModel.getNormalizedComponents(java.lang.Object, float[], int) definition code for java.awt.image.ColorModel.getNormalizedComponents(java.lang.Object, float[], int) , getNumColorComponents sample code for java.awt.image.ColorModel.getNumColorComponents() definition code for java.awt.image.ColorModel.getNumColorComponents() , getNumComponents sample code for java.awt.image.ColorModel.getNumComponents() definition code for java.awt.image.ColorModel.getNumComponents() , getPixelSize sample code for java.awt.image.ColorModel.getPixelSize() definition code for java.awt.image.ColorModel.getPixelSize() , getRed sample code for java.awt.image.ColorModel.getRed(java.lang.Object) definition code for java.awt.image.ColorModel.getRed(java.lang.Object) , getRGB sample code for java.awt.image.ColorModel.getRGB(java.lang.Object) definition code for java.awt.image.ColorModel.getRGB(java.lang.Object) , getRGBdefault sample code for java.awt.image.ColorModel.getRGBdefault() definition code for java.awt.image.ColorModel.getRGBdefault() , getTransferType sample code for java.awt.image.ColorModel.getTransferType() definition code for java.awt.image.ColorModel.getTransferType() , getUnnormalizedComponents sample code for java.awt.image.ColorModel.getUnnormalizedComponents(float[], int, int[], int) definition code for java.awt.image.ColorModel.getUnnormalizedComponents(float[], int, int[], int) , hasAlpha sample code for java.awt.image.ColorModel.hasAlpha() definition code for java.awt.image.ColorModel.hasAlpha() , hashCode sample code for java.awt.image.ColorModel.hashCode() definition code for java.awt.image.ColorModel.hashCode() , isAlphaPremultiplied sample code for java.awt.image.ColorModel.isAlphaPremultiplied() definition code for java.awt.image.ColorModel.isAlphaPremultiplied()
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

IndexColorModel sample code for java.awt.image.IndexColorModel(int, int, byte[], byte[], byte[]) definition code for java.awt.image.IndexColorModel(int, int, byte[], byte[], byte[])

public IndexColorModel(int bits,
                       int size,
                       byte[] r,
                       byte[] g,
                       byte[] b)
Constructs an IndexColorModel from the specified arrays of red, green, and blue components. Pixels described by this color model all have alpha components of 255 unnormalized (1.0 normalized), which means they are fully opaque. All of the arrays specifying the color components must have at least the specified number of entries. The ColorSpace is the default sRGB space. Since there is no alpha information in any of the arguments to this constructor, the transparency value is always Transparency.OPAQUE. The transfer type is the smallest of DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT that can hold a single pixel.

Parameters:
bits - the number of bits each pixel occupies
size - the size of the color component arrays
r - the array of red color components
g - the array of green color components
b - the array of blue color components
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if bits is less than 1 or greater than 16
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if size is less than 1

IndexColorModel sample code for java.awt.image.IndexColorModel(int, int, byte[], byte[], byte[], int) definition code for java.awt.image.IndexColorModel(int, int, byte[], byte[], byte[], int)

public IndexColorModel(int bits,
                       int size,
                       byte[] r,
                       byte[] g,
                       byte[] b,
                       int trans)
Constructs an IndexColorModel from the given arrays of red, green, and blue components. Pixels described by this color model all have alpha components of 255 unnormalized (1.0 normalized), which means they are fully opaque, except for the indicated pixel to be made transparent. All of the arrays specifying the color components must have at least the specified number of entries. The ColorSpace is the default sRGB space. The transparency value may be Transparency.OPAQUE or Transparency.BITMASK depending on the arguments, as specified in the class description above. The transfer type is the smallest of DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT that can hold a single pixel.

Parameters:
bits - the number of bits each pixel occupies
size - the size of the color component arrays
r - the array of red color components
g - the array of green color components
b - the array of blue color components
trans - the index of the transparent pixel
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if bits is less than 1 or greater than 16
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if size is less than 1

IndexColorModel sample code for java.awt.image.IndexColorModel(int, int, byte[], byte[], byte[], byte[]) definition code for java.awt.image.IndexColorModel(int, int, byte[], byte[], byte[], byte[])

public IndexColorModel(int bits,
                       int size,
                       byte[] r,
                       byte[] g,
                       byte[] b,
                       byte[] a)
Constructs an IndexColorModel from the given arrays of red, green, blue and alpha components. All of the arrays specifying the components must have at least the specified number of entries. The ColorSpace is the default sRGB space. The transparency value may be any of Transparency.OPAQUE, Transparency.BITMASK, or Transparency.TRANSLUCENT depending on the arguments, as specified in the class description above. The transfer type is the smallest of DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT that can hold a single pixel.

Parameters:
bits - the number of bits each pixel occupies
size - the size of the color component arrays
r - the array of red color components
g - the array of green color components
b - the array of blue color components
a - the array of alpha value components
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if bits is less than 1 or greater than 16
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if size is less than 1

IndexColorModel sample code for java.awt.image.IndexColorModel(int, int, byte[], int, boolean) definition code for java.awt.image.IndexColorModel(int, int, byte[], int, boolean)

public IndexColorModel(int bits,
                       int size,
                       byte[] cmap,
                       int start,
                       boolean hasalpha)
Constructs an IndexColorModel from a single array of interleaved red, green, blue and optional alpha components. The array must have enough values in it to fill all of the needed component arrays of the specified size. The ColorSpace is the default sRGB space. The transparency value may be any of Transparency.OPAQUE, Transparency.BITMASK, or Transparency.TRANSLUCENT depending on the arguments, as specified in the class description above. The transfer type is the smallest of DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT that can hold a single pixel.

Parameters:
bits - the number of bits each pixel occupies
size - the size of the color component arrays
cmap - the array of color components
start - the starting offset of the first color component
hasalpha - indicates whether alpha values are contained in the cmap array
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if bits is less than 1 or greater than 16
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if size is less than 1

IndexColorModel sample code for java.awt.image.IndexColorModel(int, int, byte[], int, boolean, int) definition code for java.awt.image.IndexColorModel(int, int, byte[], int, boolean, int)

public IndexColorModel(int bits,
                       int size,
                       byte[] cmap,
                       int start,
                       boolean hasalpha,
                       int trans)
Constructs an IndexColorModel from a single array of interleaved red, green, blue and optional alpha components. The specified transparent index represents a pixel that is made entirely transparent regardless of any alpha value specified for it. The array must have enough values in it to fill all of the needed component arrays of the specified size. The ColorSpace is the default sRGB space. The transparency value may be any of Transparency.OPAQUE, Transparency.BITMASK, or Transparency.TRANSLUCENT depending on the arguments, as specified in the class description above. The transfer type is the smallest of DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT that can hold a single pixel.

Parameters:
bits - the number of bits each pixel occupies
size - the size of the color component arrays
cmap - the array of color components
start - the starting offset of the first color component
hasalpha - indicates whether alpha values are contained in the cmap array
trans - the index of the fully transparent pixel
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if bits is less than 1 or greater than 16
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if size is less than 1

IndexColorModel sample code for java.awt.image.IndexColorModel(int, int, int[], int, boolean, int, int) definition code for java.awt.image.IndexColorModel(int, int, int[], int, boolean, int, int)

public IndexColorModel(int bits,
                       int size,
                       int[] cmap,
                       int start,
                       boolean hasalpha,
                       int trans,
                       int transferType)
Constructs an IndexColorModel from an array of ints where each int is comprised of red, green, blue, and optional alpha components in the default RGB color model format. The specified transparent index represents a pixel that is made entirely transparent regardless of any alpha value specified for it. The array must have enough values in it to fill all of the needed component arrays of the specified size. The ColorSpace is the default sRGB space. The transparency value may be any of Transparency.OPAQUE, Transparency.BITMASK, or Transparency.TRANSLUCENT depending on the arguments, as specified in the class description above.

Parameters:
bits - the number of bits each pixel occupies
size - the size of the color component arrays
cmap - the array of color components
start - the starting offset of the first color component
hasalpha - indicates whether alpha values are contained in the cmap array
trans - the index of the fully transparent pixel
transferType - the data type of the array used to represent pixel values. The data type must be either DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if bits is less than 1 or greater than 16
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if size is less than 1
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if transferType is not one of DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT

IndexColorModel sample code for java.awt.image.IndexColorModel(int, int, int[], int, int, java.math.BigInteger) definition code for java.awt.image.IndexColorModel(int, int, int[], int, int, java.math.BigInteger)

public IndexColorModel(int bits,
                       int size,
                       int[] cmap,
                       int start,
                       int transferType,
                       BigInteger sample code for java.math.BigInteger definition code for java.math.BigInteger  validBits)
Constructs an IndexColorModel from an int array where each int is comprised of red, green, blue, and alpha components in the default RGB color model format. The array must have enough values in it to fill all of the needed component arrays of the specified size. The ColorSpace is the default sRGB space. The transparency value may be any of Transparency.OPAQUE, Transparency.BITMASK, or Transparency.TRANSLUCENT depending on the arguments, as specified in the class description above. The transfer type must be one of DataBuffer.TYPE_BYTE DataBuffer.TYPE_USHORT. The BigInteger object specifies the valid/invalid pixels in the cmap array. A pixel is valid if the BigInteger value at that index is set, and is invalid if the BigInteger bit at that index is not set.

Parameters:
bits - the number of bits each pixel occupies
size - the size of the color component array
cmap - the array of color components
start - the starting offset of the first color component
transferType - the specified data type
validBits - a BigInteger object. If a bit is set in the BigInteger, the pixel at that index is valid. If a bit is not set, the pixel at that index is considered invalid. If null, all pixels are valid. Only bits from 0 to the map size are considered.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if bits is less than 1 or greater than 16
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if size is less than 1
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if transferType is not one of DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT
Method Detail

getTransparency sample code for java.awt.image.IndexColorModel.getTransparency() definition code for java.awt.image.IndexColorModel.getTransparency()

public int getTransparency()
Returns the transparency. Returns either OPAQUE, BITMASK, or TRANSLUCENT

Specified by:
getTransparency sample code for java.awt.Transparency.getTransparency() definition code for java.awt.Transparency.getTransparency() in interface Transparency sample code for java.awt.Transparency definition code for java.awt.Transparency
Overrides:
getTransparency sample code for java.awt.image.ColorModel.getTransparency() definition code for java.awt.image.ColorModel.getTransparency() in class ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel
Returns:
the transparency of this IndexColorModel
See Also:
Transparency.OPAQUE sample code for java.awt.Transparency.OPAQUE definition code for java.awt.Transparency.OPAQUE , Transparency.BITMASK sample code for java.awt.Transparency.BITMASK definition code for java.awt.Transparency.BITMASK , Transparency.TRANSLUCENT sample code for java.awt.Transparency.TRANSLUCENT definition code for java.awt.Transparency.TRANSLUCENT

getComponentSize sample code for java.awt.image.IndexColorModel.getComponentSize() definition code for java.awt.image.IndexColorModel.getComponentSize()

public int[] getComponentSize()
Returns an array of the number of bits for each color/alpha component. The array contains the color components in the order red, green, blue, followed by the alpha component, if present.

Overrides:
getComponentSize