java.awt.image

Class IndexColorModel

Implemented Interfaces:
Transparency

public class IndexColorModel
extends 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 <32alpha <321.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, ColorSpace, DataBuffer

Field Summary

Fields inherited from class java.awt.image.ColorModel

pixel_bits, transferType

Fields inherited from interface java.awt.Transparency

BITMASK, OPAQUE, TRANSLUCENT

Constructor Summary

IndexColorModel(int bits, int size, cmap[] , int start, boolean hasalpha)
Constructs an IndexColorModel from a single array of interleaved red, green, blue and optional alpha components.
IndexColorModel(int bits, int size, cmap[] , int start, boolean hasalpha, int trans)
Constructs an IndexColorModel from a single array of interleaved red, green, blue and optional alpha components.
IndexColorModel(int bits, int size, 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(int bits, int size, cmap[] , int start, int transferType, 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.
IndexColorModel(int bits, int size, r[] , g[] , b[] )
Constructs an IndexColorModel from the specified arrays of red, green, and blue components.
IndexColorModel(int bits, int size, r[] , g[] , b[] , a[] )
Constructs an IndexColorModel from the given arrays of red, green, blue and alpha components.
IndexColorModel(int bits, int size, r[] , g[] , b[] , int trans)
Constructs an IndexColorModel from the given arrays of red, green, and blue components.

Method Summary

BufferedImage
convertToIntDiscrete(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
createCompatibleSampleModel(int w, int h)
Creates a SampleModel with the specified width and height that has a data layout compatible with this ColorModel.
WritableRaster
createCompatibleWritableRaster(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()
Disposes of system resources associated with this ColorModel once this ColorModel is no longer referenced.
int
getAlpha(int pixel)
Returns the alpha component for the specified pixel, scaled from 0 to 255.
void
getAlphas(a[] )
Copies the array of alpha transparency components into the specified array.
int
getBlue(int pixel)
Returns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB.
void
getBlues(b[] )
Copies the array of blue color components into the specified array.
int[]
getComponentSize()
Returns an array of the number of bits for each color/alpha component.
int[]
getComponents(int pixel, int[] components, int offset)
Returns an array of unnormalized color/alpha components for a specified pixel in this ColorModel.
int[]
getComponents(Object pixel, int[] components, int offset)
Returns an array of unnormalized color/alpha components for a specified pixel in this ColorModel.
int
getDataElement(int[] components, int offset)
Returns a pixel value represented as an int in this ColorModel given an array of unnormalized color/alpha components.
Object
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.
Object
getDataElements(int[] components, int offset, Object pixel)
Returns a data element array representation of a pixel in this ColorModel given an array of unnormalized color/alpha components.
int
getGreen(int pixel)
Returns the green color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB.
void
getGreens(g[] )
Copies the array of green color components into the specified array.
int
getMapSize()
Returns the size of the color/alpha component arrays in this IndexColorModel.
int
getRGB(int pixel)
Returns the color/alpha components of the pixel in the default RGB color model format.
void
getRGBs(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
getRed(int pixel)
Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB.
void
getReds(r[] )
Copies the array of red color components into the specified array.
int
getTransparency()
Returns the transparency.
int
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
getValidPixels()
Returns a BigInteger that indicates the valid/invalid pixels in the colormap.
boolean
isCompatibleRaster(Raster raster)
Returns true if raster is compatible with this ColorModel or false if it is not compatible with this ColorModel.
boolean
isCompatibleSampleModel(SampleModel sm)
Checks if the specified SampleModel is compatible with this ColorModel.
boolean
isValid()
Returns whether or not all of the pixels are valid.
boolean
isValid(int pixel)
Returns whether or not the pixel is valid.
String
toString()
Returns the String representation of the contents of this ColorModelobject.

Methods inherited from class java.awt.image.ColorModel

coerceData, createCompatibleSampleModel, createCompatibleWritableRaster, equals, finalize, getAlpha, getAlpha, getAlphaRaster, getBlue, getBlue, getColorSpace, getComponentSize, getComponentSize, getComponents, getComponents, getDataElement, getDataElement, getDataElements, getDataElements, getDataElements, getGreen, getGreen, getNormalizedComponents, getNormalizedComponents, getNumColorComponents, getNumComponents, getPixelSize, getRGB, getRGB, getRGBdefault, getRed, getRed, getTransferType, getTransparency, getUnnormalizedComponents, hasAlpha, hashCode, isAlphaPremultiplied, isCompatibleRaster, isCompatibleSampleModel, toString

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

IndexColorModel

public IndexColorModel(int bits,
                       int size,
                       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
start - the starting offset of the first color component
hasalpha - indicates whether alpha values are contained in the cmap array
Throws:
IllegalArgumentException - if bits is less than 1 or greater than 16
IllegalArgumentException - if size is less than 1
Usages and Demos :

View More Examples of IndexColorModel(int bits,int size,cmap[] ,int start,boolean hasalpha)
   1:         }
   2:         Graycolormodel = new IndexColorModel(8, 256, g, g, g);
   3:     }
   4: 
   5:     private native void readImage(InputStream is, byte buf[])

View Full Code Here
   1:     offset += 4*N;
   2:     return new IndexColorModel(8, N, r, g, b);
   3:     }
   4: 
   5:     protected void skipToImage(ImageInputStream in) throws IOException {

View Full Code Here
   1:       c[i] = (byte)(255.0 * (((double)i) / ((double)c.length - 1.0)));
   2:     return new IndexColorModel(8, c.length, c, c, c);
   3:   }
   4: 
   5:   public byte[] getRaster()

View Full Code Here
   1:     
   2:     return new IndexColorModel(8, 256, r, g, b);
   3:     }
   4:     
   5:     protected int loadColor(int index) {

View Full Code Here
   1: 
   2:         cModel=new IndexColorModel(8,256,palRed,palGreen,palBlue);
   3: 
   4:         if(bImage!=null && !dataChange) {

View Full Code Here

IndexColorModel

public IndexColorModel(int bits,
                       int size,
                       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
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 - if bits is less than 1 or greater than 16
IllegalArgumentException - if size is less than 1
Usages and Demos :

View More Examples of IndexColorModel(int bits,int size,cmap[] ,int start,boolean hasalpha,int trans)
   1:     if ( next_object instanceof Integer ) {
   2:         model = new IndexColorModel(8, reds.length, reds, greens, blues, ((Integer) next_object).intValue());
   3:     }
   4:         ...
   5:     else {
   6:         model = new IndexColorModel(8, reds.length, reds, greens, blues, (byte[]) next_object);
   7:     }
   8:     }
   9: }

View Full Code Here
   1:     a[f.getTransparentIndex()] = 0;
   2:     return new IndexColorModel(8, nc, r, g, b, a);
   3:       }
   4:     
   5:     return new IndexColorModel(8, nc, r, g, b);

View Full Code Here
   1:         if (data.transparentPixel != -1) {
   2:             colorModel = new IndexColorModel(data.depth, rgbs.length, red, green, blue, data.transparentPixel);
   3:         } else {
   4:             colorModel = new IndexColorModel(data.depth, rgbs.length, red, green, blue);
   5:         }        

View Full Code Here
   1:                             indexCModel.getBlues(bbuf);
   2:                             indexCModel = new IndexColorModel(8, map_size, rbuf, gbuf, bbuf, alpha_buf);
   3:                         }
   4:                     }
   5:                     break;

View Full Code Here

IndexColorModel

public IndexColorModel(int bits,
                       int size,
                       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
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 - if bits is less than 1 or greater than 16
IllegalArgumentException - if size is less than 1
IllegalArgumentException - if transferType is not one of DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT
Usages and Demos :

View More Examples of IndexColorModel(int bits,int size,cmap[] ,int start,boolean hasalpha,int trans,int transferType)
   1:         if (numBands == 1) {
   2:             return new IndexColorModel(bits, ARGB.length, ARGB, 0, hasAlpha, transparent, type);
   3:         } else {
   4:             return new MultiBandsIndexColorModel(bits, ARGB.length, ARGB, 0, hasAlpha, transparent,
   5:                                                  type, numBands, visibleBand);

View Full Code Here
   1:         if (numBands == 1) {
   2:             return new IndexColorModel(bits, length, ARGB, 0, hasAlpha, transparent, type);
   3:         } else {
   4:             return new MultiBandsIndexColorModel(bits, length, ARGB, 0, hasAlpha, transparent,
   5:                                                  type, numBands, visibleBand);

View Full Code Here

IndexColorModel

public IndexColorModel(int bits,
                       int size,
                       cmap[] ,
                       int start,
                       int transferType,
                       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
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 - if bits is less than 1 or greater than 16
IllegalArgumentException - if size is less than 1
IllegalArgumentException - if transferType is not one of DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT
Usages and Demos :

View More Examples of IndexColorModel(int bits,int size,cmap[] ,int start,int transferType,BigInteger validBits)
   1:     if ( next_object instanceof Integer ) {
   2:         model = new IndexColorModel(8, reds.length, reds, greens, blues, ((Integer) next_object).intValue());
   3:     }
   4:         ...
   5:     else {
   6:         model = new IndexColorModel(8, reds.length, reds, greens, blues, (byte[]) next_object);
   7:     }
   8:     }
   9: }

View Full Code Here
   1:     a[f.getTransparentIndex()] = 0;
   2:     return new IndexColorModel(8, nc, r, g, b, a);
   3:       }
   4:     
   5:     return new IndexColorModel(8, nc, r, g, b);

View Full Code Here
   1:         if (data.transparentPixel != -1) {
   2:             colorModel = new IndexColorModel(data.depth, rgbs.length, red, green, blue, data.transparentPixel);
   3:         } else {
   4:             colorModel = new IndexColorModel(data.depth, rgbs.length, red, green, blue);
   5:         }        

View Full Code Here
   1:                             indexCModel.getBlues(bbuf);
   2:                             indexCModel = new IndexColorModel(8, map_size, rbuf, gbuf, bbuf, alpha_buf);
   3:                         }
   4:                     }
   5:                     break;

View Full Code Here

IndexColorModel

public IndexColorModel(int bits,
                       int size,
                       r[] ,
                       g[] ,
                       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
Throws:
IllegalArgumentException - if bits is less than 1 or greater than 16
IllegalArgumentException - if size is less than 1
Usages and Demos :

View More Examples of IndexColorModel(int bits,int size,r[] ,g[] ,b[] )
   1:         }
   2:         Graycolormodel = new IndexColorModel(8, 256, g, g, g);
   3:     }
   4: 
   5:     private native void readImage(InputStream is, byte buf[])

View Full Code Here
   1:     offset += 4*N;
   2:     return new IndexColorModel(8, N, r, g, b);
   3:     }
   4: 
   5:     protected void skipToImage(ImageInputStream in) throws IOException {

View Full Code Here
   1:       c[i] = (byte)(255.0 * (((double)i) / ((double)c.length - 1.0)));
   2:     return new IndexColorModel(8, c.length, c, c, c);
   3:   }
   4: 
   5:   public byte[] getRaster()

View Full Code Here
   1:     
   2:     return new IndexColorModel(8, 256, r, g, b);
   3:     }
   4:     
   5:     protected int loadColor(int index) {

View Full Code Here
   1: 
   2:         cModel=new IndexColorModel(8,256,palRed,palGreen,palBlue);
   3: 
   4:         if(bImage!=null && !dataChange) {

View Full Code Here

IndexColorModel

public IndexColorModel(int bits,
                       int size,
                       r[] ,
                       g[] ,
                       b[] ,
                       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
Throws:
IllegalArgumentException - if bits is less than 1 or greater than 16
IllegalArgumentException - if size is less than 1
Usages and Demos :

View More Examples of IndexColorModel(int bits,int size,r[] ,g[] ,b[] ,a[] )
   1:     if ( next_object instanceof Integer ) {
   2:         model = new IndexColorModel(8, reds.length, reds, greens, blues, ((Integer) next_object).intValue());
   3:     }
   4:         ...
   5:     else {
   6:         model = new IndexColorModel(8, reds.length, reds, greens, blues, (byte[]) next_object);
   7:     }
   8:     }
   9: }

View Full Code Here
   1:     a[f.getTransparentIndex()] = 0;
   2:     return new IndexColorModel(8, nc, r, g, b, a);
   3:       }
   4:     
   5:     return new IndexColorModel(8, nc, r, g, b);

View Full Code Here
   1:         if (data.transparentPixel != -1) {
   2:             colorModel = new IndexColorModel(data.depth, rgbs.length, red, green, blue, data.transparentPixel);
   3:         } else {
   4:             colorModel = new IndexColorModel(data.depth, rgbs.length, red, green, blue);
   5:         }        

View Full Code Here
   1:                             indexCModel.getBlues(bbuf);
   2:                             indexCModel = new IndexColorModel(8, map_size, rbuf, gbuf, bbuf, alpha_buf);
   3:                         }
   4:                     }
   5:                     break;

View Full Code Here

IndexColorModel

public IndexColorModel(int bits,
                       int size,
                       r[] ,
                       g[] ,
                       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
trans - the index of the transparent pixel
Throws:
IllegalArgumentException - if bits is less than 1 or greater than 16
IllegalArgumentException - if size is less than 1
Usages and Demos :

View More Examples of IndexColorModel(int bits,int size,r[] ,g[] ,b[] ,int trans)
   1:     if ( next_object instanceof Integer ) {
   2:         model = new IndexColorModel(8, reds.length, reds, greens, blues, ((Integer) next_object).intValue());
   3:     }
   4:         ...
   5:     else {
   6:         model = new IndexColorModel(8, reds.length, reds, greens, blues, (byte[]) next_object);
   7:     }
   8:     }
   9: }

View Full Code Here
   1:     a[f.getTransparentIndex()] = 0;
   2:     return new IndexColorModel(8, nc, r, g, b, a);
   3:       }
   4:     
   5:     return new IndexColorModel(8, nc, r, g, b);

View Full Code Here
   1:         if (data.transparentPixel != -1) {
   2:             colorModel = new IndexColorModel(data.depth, rgbs.length, red, green, blue, data.transparentPixel);
   3:         } else {
   4:             colorModel = new IndexColorModel(data.depth, rgbs.length, red, green, blue);
   5:         }        

View Full Code Here
   1:                             indexCModel.getBlues(bbuf);
   2:                             indexCModel = new IndexColorModel(8, map_size, rbuf, gbuf, bbuf, alpha_buf);
   3:                         }
   4:                     }
   5:                     break;

View Full Code Here

Method Details

convertToIntDiscrete

public BufferedImage convertToIntDiscrete(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. If forceARGB is true, a TYPE_INT_ARGB image is returned regardless of whether or not this ColorModel has an alpha component array or a transparent pixel.
Parameters:
raster - the specified Raster
forceARGB - if true, the returned BufferedImage is TYPE_INT_ARGB; otherwise it is TYPE_INT_RGB
Returns:
a BufferedImage created with the specified Raster
Throws:
IllegalArgumentException - if the raster argument is not compatible with this IndexColorModel

createCompatibleSampleModel

public SampleModel createCompatibleSampleModel(int w,
                                               int h)
Creates a SampleModel with the specified width and height that has a data layout compatible with this ColorModel.
Overrides:
createCompatibleSampleModel in interface ColorModel
Parameters:
w - the width to apply to the new SampleModel
h - the height to apply to the new SampleModel
Returns:
a SampleModel object with the specified width and height.
Throws:
IllegalArgumentException - if w or h is not greater than 0
See Also:
SampleModel

createCompatibleWritableRaster

public WritableRaster createCompatibleWritableRaster(int w,
                                                     int h)
Creates a WritableRaster with the specified width and height that has a data layout (SampleModel) compatible with this ColorModel. This method only works for color models with 16 or fewer bits per pixel.

Since IndexColorModel can be subclassed, any subclass that supports greater than 16 bits per pixel must override this method.

Overrides:
createCompatibleWritableRaster in interface ColorModel
Parameters:
w - the width to apply to the new WritableRaster
h - the height to apply to the new WritableRaster
Returns:
a WritableRaster object with the specified width and height.
Throws:
UnsupportedOperationException - if the number of bits in a pixel is greater than 16
Usages and Demos :

View More Examples of createCompatibleWritableRaster(int w,int h)
   1: import java.awt.image.DataBuffer;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.RenderedImage;
   4:         ...
   5: 
   6:         final WritableRaster raster = cm.createCompatibleWritableRaster(width, height);
   7:         final BufferedImage result = new BufferedImage(cm, raster, isAlphaPremultiplied, properties);
   8:         ...
   9: 
  10:         if((cm instanceof IndexColorModel) &&
  11:         ...
  12:            (((IndexColorModel) cm).getMapSize() <= maxColours) &&

View Full Code Here

finalize

public void finalize()
Disposes of system resources associated with this ColorModel once this ColorModel is no longer referenced.
Overrides:
finalize in interface ColorModel

getAlpha

public final int getAlpha(int pixel)
Returns the alpha component for the specified pixel, scaled from 0 to 255. The pixel value is specified as an int.
Overrides:
getAlpha in interface ColorModel
Parameters:
pixel - the specified pixel
Returns:
the value of the alpha component for the specified pixel
Usages and Demos :

View More Examples of getAlpha(int pixel)
   1: import java.awt.image.RenderedImage;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.font.FontRenderContext;
   4:         ...
   5: 
   6:     public boolean setColors(final IndexColorModel model) {
   7:         final Color[] colors;
   8:         ...
   9:                                       model.getBlue (i),
  10:                                       model.getAlpha(i));
  11:             }

View Full Code Here
   1: import java.awt.image.RenderedImage;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.font.FontRenderContext;
   4:         ...
   5: 
   6:     public boolean setColors(final IndexColorModel model) {
   7:         return (model!=null) ? setColors(model, 0, model.getMapSize()) : setColors(EMPTY);
   8:         ...
   9: 
  10:     private boolean setColors(final IndexColorModel model, final int lower, final int upper) {
  11:         if (model == null) {
  12:         ...
  13:                                   model.getBlue (j),
  14:                                   model.getAlpha(j));

View Full Code Here
   1: import java.awt.image.DirectColorModel;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.PackedColorModel;
   4:         ...
   5:         final ColorModel cm = image.getColorModel();
   6:         return (cm instanceof IndexColorModel) ? ((IndexColorModel) cm)
   7:                 .getTransparentPixel() : -1;
   8:         ...
   9:     public final boolean isIndexed() {
  10:         return image.getColorModel() instanceof IndexColorModel;
  11:     }
  12:         ...
  13:                 for (int i = 0; i < mapSize; i++) {
  14:                     table[i] = (byte) ((oldCM.getAlpha(i) == 0) ? transparent

View Full Code Here

getAlphas

public final void getAlphas(a[] )
Copies the array of alpha transparency components into the specified array. Only the initial entries of the array as specified by getMapSize are written.
Parameters:
Usages and Demos :

View More Examples of getAlphas(a[] )
   1:     
   2:     IndexColorModel        model;
   3:     
   4:         ...
   5:     
   6:     public IndexColorModelSerializer(IndexColorModel m) {
   7:     model = m;
   8:         ...
   9:     
  10:     public IndexColorModel getModel() {
  11:     return model;
  12:         ...
  13:         byte[] alpha_bytes = new byte[map_size];
  14:         model.getAlphas(alpha_bytes);

View Full Code Here
   1:     public void setColorModel(ColorModel model) {
   2:     if (model instanceof IndexColorModel && true) {
   3:         ...
   4:         IndexColorModel icm = (IndexColorModel) model;
   5:         models[0] = filterIndexColorModel(icm, false, false, 0);
   6:         ...
   7:     if (opaque) {
   8:         icm.getAlphas(a);
   9:         for (int i = 0; i < mapsize; i++) {

View Full Code Here
   1:   {
   2:     if (model instanceof IndexColorModel && true)
   3:     {
   4:         ...
   5:       IndexColorModel icm = (IndexColorModel) model;
   6: 
   7:         ...
   8:     {
   9:       icm.getAlphas(a);
  10:       for (int i = 0; i < mapsize; i++)

View Full Code Here
   1: import java.awt.image.ColorModel;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.Raster;
   4:         ...
   5:         ColorModel colorModel = image.getColorModel();
   6:         if (colorModel instanceof IndexColorModel) {
   7:             if (bitDepth < 1 || bitDepth > 8) {
   8:         ...
   9: 
  10:             IndexColorModel icm = (IndexColorModel)colorModel;
  11:             int size = icm.getMapSize();
  12:         ...
  13:             icm.getBlues(bluePalette);
  14:             icm.getAlphas(alphaPalette);

View Full Code Here
   1: import java.awt.image.ColorModel;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.Raster;
   4:         ...
   5:         ColorModel colorModel = image.getColorModel();
   6:         if (colorModel instanceof IndexColorModel) {
   7:             if (bitDepth < 1 || bitDepth > 8) {
   8:         ...
   9: 
  10:             IndexColorModel icm = (IndexColorModel)colorModel;
  11:             int size = icm.getMapSize();
  12:         ...
  13:             icm.getBlues(bluePalette);
  14:             icm.getAlphas(alphaPalette);

View Full Code Here

getBlue

public final int getBlue(int pixel)
Returns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. The pixel value is specified as an int. The returned value is a non pre-multiplied value.
Overrides:
getBlue in interface ColorModel
Parameters:
pixel - the specified pixel
Returns:
the value of the blue color component for the specified pixel
Usages and Demos :

View More Examples of getBlue(int pixel)
   1: import java.awt.image.RenderedImage;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.font.FontRenderContext;
   4:         ...
   5: 
   6:     public boolean setColors(final IndexColorModel model) {
   7:         final Color[] colors;
   8:         ...
   9:                                       model.getGreen(i),
  10:                                       model.getBlue(i),
  11:                                       model.getAlpha(i));

View Full Code Here
   1: import java.awt.image.RenderedImage;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.font.FontRenderContext;
   4:         ...
   5: 
   6:     public boolean setColors(final IndexColorModel model) {
   7:         return (model!=null) ? setColors(model, 0, model.getMapSize()) : setColors(EMPTY);
   8:         ...
   9: 
  10:     private boolean setColors(final IndexColorModel model, final int lower, final int upper) {
  11:         if (model == null) {
  12:         ...
  13:                                   model.getGreen(j),
  14:                                   model.getBlue(j),

View Full Code Here

getBlues

public final void getBlues(b[] )
Copies the array of blue color components into the specified array. Only the initial entries of the array as specified by getMapSize are written.
Parameters:
Usages and Demos :

View More Examples of getBlues(b[] )
   1: import java.awt.image.DirectColorModel;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5:         return data;        
   6:     } else if (bufferedImage.getColorModel() instanceof IndexColorModel) {
   7:         ...
   8:         IndexColorModel colorModel = (IndexColorModel)bufferedImage.getColorModel();
   9:         int size = colorModel.getMapSize();
  10:         ...
  11:         colorModel.getGreens(greens);
  12:         colorModel.getBlues(blues);

View Full Code Here
   1: import java.awt.image.BufferedImage;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5: {
   6:     private static final String INVALID_COLOR_MODEL_MSG = "This builder works with IndexColorModel only. CurrentModel = ";
   7: 
   8:         ...
   9: 
  10:         IndexColorModel indexColorModel = getIndexColorModel();
  11: 
  12:         ...
  13:         indexColorModel.getGreens(greens);
  14:         indexColorModel.getBlues(blues);

View Full Code Here
   1:     
   2:     IndexColorModel        model;
   3:     
   4:         ...
   5:     
   6:     public IndexColorModelSerializer(IndexColorModel m) {
   7:     model = m;
   8:         ...
   9:     
  10:     public IndexColorModel getModel() {
  11:     return model;
  12:         ...
  13:     stream.writeObject(green_bytes);
  14:     model.getBlues(blue_bytes);

View Full Code Here
   1:     public void setColorModel(ColorModel model) {
   2:     if (model instanceof IndexColorModel && true) {
   3:         ...
   4:         IndexColorModel icm = (IndexColorModel) model;
   5:         models[0] = filterIndexColorModel(icm, false, false, 0);
   6:         ...
   7:     icm.getGreens(g);
   8:     icm.getBlues(b);
   9:     if (opaque) {

View Full Code Here
   1:   {
   2:     if (model instanceof IndexColorModel && true)
   3:     {
   4:         ...
   5:       IndexColorModel icm = (IndexColorModel) model;
   6: 
   7:         ...
   8:     icm.getGreens(g);
   9:     icm.getBlues(b);
  10:     if (opaque)

View Full Code Here

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 in interface ColorModel
Returns:
an array containing the number of bits of each color and alpha component of this IndexColorModel

getComponents

public int[] getComponents(int pixel,
                           int[] components,
                           int offset)
Returns an array of unnormalized color/alpha components for a specified pixel in this ColorModel. The pixel value is specified as an int. If the components array is null, a new array is allocated that contains offset + getNumComponents() elements. The components array is returned, with the alpha component included only if hasAlpha returns true. Color/alpha components are stored in the components array starting at offset even if the array is allocated by this method. An ArrayIndexOutOfBoundsException is thrown if the components array is not null and is not large enough to hold all the color and alpha components starting at offset.
Overrides:
getComponents in interface ColorModel
Parameters:
pixel - the specified pixel
components - the array to receive the color and alpha components of the specified pixel
offset - the offset into the components array at which to start storing the color and alpha components
Returns:
an array containing the color and alpha components of the specified pixel starting at the specified offset.

getComponents

public int[] getComponents(Object pixel,
                           int[] components,
                           int offset)
Returns an array of unnormalized color/alpha components for a specified pixel in this ColorModel. The pixel value is specified by an array of data elements of type transferType passed in as an object reference. If pixel is not a primitive array of type transferType, a ClassCastException is thrown. An ArrayIndexOutOfBoundsException is thrown if pixel is not large enough to hold a pixel value for this ColorModel. If the components array is null, a new array is allocated that contains offset + getNumComponents() elements. The components array is returned, with the alpha component included only if hasAlpha returns true. Color/alpha components are stored in the components array starting at offset even if the array is allocated by this method. An ArrayIndexOutOfBoundsException is also thrown if the components array is not null and is not large enough to hold all the color and alpha components starting at offset.

Since IndexColorModel 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 unsupported transferType.

Overrides:
getComponents in interface ColorModel
Parameters:
pixel - the specified pixel
components - an array that receives the color and alpha components of the specified pixel
offset - the index into the components array at which to begin storing the color and alpha components of the specified pixel
Returns:
an array containing the color and alpha components of the specified pixel starting at the specified offset.
Throws:
ArrayIndexOutOfBoundsException - if pixel is not large enough to hold a pixel value for this ColorModel or if the components array is not null and is not large enough to hold all the color and alpha components starting at offset
ClassCastException - if pixel is not a primitive array of type transferType
UnsupportedOperationException - if transferType is not one of the supported transer types

getDataElement

public int getDataElement(int[] components,
                          int offset)
Returns a pixel value represented as an int in this ColorModel given an array of unnormalized color/alpha components. An ArrayIndexOutOfBoundsException is thrown if the components array is not large enough to hold all of the color and alpha components starting at offset. Since ColorModel 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 unsupported transferType.
Overrides:
getDataElement in interface ColorModel
Parameters:
components - an array of unnormalized color and alpha components
offset - the index into components at which to begin retrieving the color and alpha components
Returns:
an int pixel value in this ColorModel corresponding to the specified components.
Throws:
ArrayIndexOutOfBoundsException - if the components array is not large enough to hold all of the color and alpha components starting at offset
UnsupportedOperationException - if transferType is invalid

getDataElements

public Object 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. This array can then be passed to the setDataElements method of a WritableRaster object. If the pixel variable is null, a new array is allocated. If pixel is not null, it must be a primitive array of type transferType; otherwise, a ClassCastException is thrown. An ArrayIndexOutOfBoundsException is thrown if pixel is not large enough to hold a pixel value for this ColorModel. The pixel array is returned.

Since IndexColorModel 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 unsupported transferType.

Overrides:
getDataElements in interface ColorModel
Parameters:
rgb - the integer pixel representation in the default RGB color model
pixel - the specified pixel
Returns:
an array representation of the specified pixel in this IndexColorModel.
Throws:
ClassCastException - if pixel is not a primitive array of type transferType
ArrayIndexOutOfBoundsException - if pixel is not large enough to hold a pixel value for this ColorModel
UnsupportedOperationException - if transferType is invalid
See Also:
WritableRaster.setDataElements, SampleModel.setDataElements

getDataElements

public Object getDataElements(int[] components,
                              int offset,
                              Object pixel)
Returns a data element array representation of a pixel in this ColorModel given an array of unnormalized color/alpha components. This array can then be passed to the setDataElements method of a WritableRaster object. An ArrayIndexOutOfBoundsException is thrown if the components array is not large enough to hold all of the color and alpha components starting at offset. If the pixel variable is null, a new array is allocated. If pixel is not null, it must be a primitive array of type transferType; otherwise, a ClassCastException is thrown. An ArrayIndexOutOfBoundsException is thrown if pixel is not large enough to hold a pixel value for this ColorModel.

Since IndexColorModel 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 unsupported transferType

Overrides:
getDataElements in interface ColorModel
Parameters:
components - an array of unnormalized color and alpha components
offset - the index into components at which to begin retrieving color and alpha components
pixel - the Object representing an array of color and alpha components
Returns:
an Object representing an array of color and alpha components.
Throws:
ClassCastException - if pixel is not a primitive array of type transferType
ArrayIndexOutOfBoundsException - if pixel is not large enough to hold a pixel value for this ColorModel or the components array is not large enough to hold all of the color and alpha components starting at offset
UnsupportedOperationException - if transferType is not one of the supported transer types
See Also:
WritableRaster.setDataElements, SampleModel.setDataElements

getGreen

public final int getGreen(int pixel)
Returns the green color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. The pixel value is specified as an int. The returned value is a non pre-multiplied value.
Overrides:
getGreen in interface ColorModel
Parameters:
pixel - the specified pixel
Returns:
the value of the green color component for the specified pixel
Usages and Demos :

View More Examples of getGreen(int pixel)
   1: import java.awt.image.RenderedImage;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.font.FontRenderContext;
   4:         ...
   5: 
   6:     public boolean setColors(final IndexColorModel model) {
   7:         final Color[] colors;
   8:         ...
   9:                 colors[i] = new Color(model.getRed  (i),
  10:                                       model.getGreen(i),
  11:                                       model.getBlue (i),

View Full Code Here
   1: import java.awt.image.RenderedImage;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.font.FontRenderContext;
   4:         ...
   5: 
   6:     public boolean setColors(final IndexColorModel model) {
   7:         return (model!=null) ? setColors(model, 0, model.getMapSize()) : setColors(EMPTY);
   8:         ...
   9: 
  10:     private boolean setColors(final IndexColorModel model, final int lower, final int upper) {
  11:         if (model == null) {
  12:         ...
  13:             colors[i] = new Color(model.getRed  (j),
  14:                                   model.getGreen(j),

View Full Code Here

getGreens

public final void getGreens(g[] )
Copies the array of green color components into the specified array. Only the initial entries of the array as specified by getMapSize are written.
Parameters:
Usages and Demos :

View More Examples of getGreens(g[] )
   1: import java.awt.image.DirectColorModel;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5:         return data;        
   6:     } else if (bufferedImage.getColorModel() instanceof IndexColorModel) {
   7:         ...
   8:         IndexColorModel colorModel = (IndexColorModel)bufferedImage.getColorModel();
   9:         int size = colorModel.getMapSize();
  10:         ...
  11:         colorModel.getReds(reds);
  12:         colorModel.getGreens(greens);

View Full Code Here
   1: import java.awt.image.BufferedImage;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5: {
   6:     private static final String INVALID_COLOR_MODEL_MSG = "This builder works with IndexColorModel only. CurrentModel = ";
   7: 
   8:         ...
   9: 
  10:         IndexColorModel indexColorModel = getIndexColorModel();
  11: 
  12:         ...
  13:         indexColorModel.getReds(reds);
  14:         indexColorModel.getGreens(greens);

View Full Code Here
   1:     
   2:     IndexColorModel        model;
   3:     
   4:         ...
   5:     
   6:     public IndexColorModelSerializer(IndexColorModel m) {
   7:     model = m;
   8:         ...
   9:     
  10:     public IndexColorModel getModel() {
  11:     return model;
  12:         ...
  13:     stream.writeObject(red_bytes);
  14:     model.getGreens(green_bytes);

View Full Code Here
   1:     public void setColorModel(ColorModel model) {
   2:     if (model instanceof IndexColorModel && true) {
   3:         ...
   4:         IndexColorModel icm = (IndexColorModel) model;
   5:         models[0] = filterIndexColorModel(icm, false, false, 0);
   6:         ...
   7:     icm.getReds(r);
   8:     icm.getGreens(g);
   9:     icm.getBlues(b);

View Full Code Here
   1:   {
   2:     if (model instanceof IndexColorModel && true)
   3:     {
   4:         ...
   5:       IndexColorModel icm = (IndexColorModel) model;
   6: 
   7:         ...
   8:     icm.getReds(r);
   9:     icm.getGreens(g);
  10:     icm.getBlues(b);

View Full Code Here

getMapSize

public final int getMapSize()
Returns the size of the color/alpha component arrays in this IndexColorModel.
Returns:
the size of the color and alpha component arrays.
Usages and Demos :

View More Examples of getMapSize()
   1: import java.awt.color.ColorSpace;
   2: import java.awt.image.IndexColorModel;
   3: 
   4:         ...
   5: 
   6:   public PNGPalette( IndexColorModel cm )
   7:   {
   8:         ...
   9:     super( TYPE_PALETTE );
  10:     int n = cm.getMapSize();
  11:     data = new byte[ n * 3 ];
  12:         ...
  13: 
  14:   public IndexColorModel getPalette( ColorSpace cs )

View Full Code Here
   1: import java.awt.image.DirectColorModel;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5:         return data;        
   6:     } else if (bufferedImage.getColorModel() instanceof IndexColorModel) {
   7:         ...
   8:         IndexColorModel colorModel = (IndexColorModel)bufferedImage.getColorModel();
   9:         ...
  10:         int size = colorModel.getMapSize();

View Full Code Here
   1:     
   2:     IndexColorModel        model;
   3:     
   4:         ...
   5:     
   6:     public IndexColorModelSerializer(IndexColorModel m) {
   7:     model = m;
   8:         ...
   9:     
  10:     public IndexColorModel getModel() {
  11:     return model;
  12:         ...
  13:     
  14:     int map_size = model.getMapSize();

View Full Code Here
   1: import java.awt.image.ColorModel;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.RenderedImage;
   4:         ...
   5:                 image.getColorModel() : band.getColorModel();
   6:             if (!(candidate instanceof IndexColorModel)) {
   7:                 throw new IllegalArgumentException(
   8:         ...
   9:                         "Current implementation requires IndexColorModel");
  10:             }
  11:         ...
  12:             final IndexColorModel colors = (IndexColorModel) candidate;
  13:             final int mapSize = colors.getMapSize();

View Full Code Here
   1: import java.awt.image.RenderedImage;
   2: import java.awt.image.IndexColorModel;
   3: 
   4:         ...
   5:                                                           :  band.getColorModel();
   6:             if (!(candidate instanceof IndexColorModel)) {
   7:         ...
   8:                 throw new IllegalArgumentException("Current implementation requires IndexColorModel");
   9:             }
  10:         ...
  11:             final IndexColorModel  colors = (IndexColorModel) candidate;
  12:             final int             mapSize = colors.getMapSize();

View Full Code Here

getRGB

public final int getRGB(int pixel)
Returns the color/alpha components of the pixel in the default RGB color model format. The pixel value is specified as an int. The returned value is in a non pre-multiplied format.
Overrides:
getRGB in interface ColorModel
Parameters:
pixel - the specified pixel
Returns:
the color and alpha components of the specified pixel
Usages and Demos :

View More Examples of getRGB(int pixel)
   1:     public void setColorModel(ColorModel model) {
   2:     if (model instanceof IndexColorModel && true) {
   3:         ...
   4:         IndexColorModel icm = (IndexColorModel) model;
   5:         models[0] = filterIndexColorModel(icm, false, false, 0);
   6:         ...
   7:         for (int i = 0; i < mapsize; i++) {
   8:         int rgb = filterRGB(icm.getRGB(i), brighter, percent);
   9:         a[i] = (byte) (rgb >> 24);

View Full Code Here
   1:   {
   2:     if (model instanceof IndexColorModel && true)
   3:     {
   4:         ...
   5:       IndexColorModel icm = (IndexColorModel) model;
   6: 
   7:         ...
   8:       {
   9:         int rgb = filterRGB(icm.getRGB(i), brighter, percent);

View Full Code Here

getRGBs

public final void getRGBs(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. Only the initial entries of the array as specified by getMapSize are written.
Parameters:
Usages and Demos :

View More Examples of getRGBs(rgb[] )
   1: import java.awt.image.ColorModel;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.RenderedImage;
   4:         ...
   5:                 image.getColorModel() : band.getColorModel();
   6:             if (!(candidate instanceof IndexColorModel)) {
   7:                 throw new IllegalArgumentException(
   8:         ...
   9:                         "Current implementation requires IndexColorModel");
  10:             }
  11:         ...
  12:             final int[] ARGB = new int[mapSize];
  13:             colors.getRGBs(ARGB);

View Full Code Here
   1: import java.awt.image.RenderedImage;
   2: import java.awt.image.IndexColorModel;
   3: 
   4:         ...
   5:                                                           :  band.getColorModel();
   6:             if (!(candidate instanceof IndexColorModel)) {
   7:         ...
   8:                 throw new IllegalArgumentException("Current implementation requires IndexColorModel");
   9:             }
  10:         ...
  11:             final int[]              ARGB = new int[mapSize];
  12:             colors.getRGBs(ARGB);

View Full Code Here
   1: import java.awt.image.ColorModel;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.RenderedImage;
   4:         ...
   5:             ColorModel colors = sourceImage.getColorModel();
   6:             if (colors instanceof IndexColorModel &&
   7:                 sourceBands[visibleSourceBand].equals(targetBands[visibleTargetBand]))
   8:         ...
   9:             {
  10:                 final IndexColorModel indexed = (IndexColorModel) colors;
  11:                 final int[] ARGB = new int[indexed.getMapSize()];
  12:         ...
  13:                 indexed.getRGBs(ARGB);

View Full Code Here
   1:     private static int[] getARGB(final GridCoverage coverage) {
   2:         IndexColorModel colors = (IndexColorModel) coverage.getRenderedImage().getColorModel();
   3:         final int[] ARGB = new int[colors.getMapSize()];
   4:         ...
   5:         colors.getRGBs(ARGB);
   6:         return ARGB;
   7:     }

View Full Code Here
   1: import java.awt.image.ColorModel;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.RenderedImage;
   4:         ...
   5:             ColorModel colors = image.getColorModel();
   6:             if (colors instanceof IndexColorModel &&
   7:                 sourceBands[visibleSourceBand].equals(targetBands[visibleTargetBand]))
   8:         ...
   9:             {
  10:                 final IndexColorModel indexed = (IndexColorModel) colors;
  11:                 final int[] ARGB = new int[indexed.getMapSize()];
  12:         ...
  13:                 indexed.getRGBs(ARGB);

View Full Code Here

getRed

public final int getRed(int pixel)
Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. The pixel value is specified as an int. The returned value is a non pre-multiplied value.
Overrides:
getRed in interface ColorModel
Parameters:
pixel - the specified pixel
Returns:
the value of the red color component for the specified pixel
Usages and Demos :

View More Examples of getRed(int pixel)
   1: import java.awt.color.ColorSpace;
   2: import java.awt.image.IndexColorModel;
   3: 
   4:         ...
   5: 
   6:   public PNGPalette( IndexColorModel cm )
   7:   {
   8:         ...
   9:       {
  10:     red[i] = data[i * 3] = (byte)cm.getRed(i);
  11:     green[i] = data[i * 3 + 1] = (byte)cm.getGreen(i);
  12:         ...
  13: 
  14:   public IndexColorModel getPalette( ColorSpace cs )

View Full Code Here
   1: import java.awt.Color;
   2: import java.awt.image.IndexColorModel;
   3: 
   4:         ...
   5:     private byte[] buffer;
   6:     private IndexColorModel palette;
   7:     private short[] shadeTable;
   8:         ...
   9:         int widthBits, int heightBits,
  10:         IndexColorModel palette)
  11:     {
  12:         ...
  13:             for (int i=0; i<palette.getMapSize(); i++) {
  14:                 int red = calcColor(palette.getRed(i),

View Full Code Here

getReds

public final void getReds(r[] )
Copies the array of red color components into the specified array. Only the initial entries of the array as specified by getMapSize are written.
Parameters:
Usages and Demos :

View More Examples of getReds(r[] )
   1: import java.awt.image.DirectColorModel;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5:         return data;        
   6:     } else if (bufferedImage.getColorModel() instanceof IndexColorModel) {
   7:         ...
   8:         IndexColorModel colorModel = (IndexColorModel)bufferedImage.getColorModel();
   9:         int size = colorModel.getMapSize();
  10:         ...
  11:         byte[] blues = new byte[size];
  12:         colorModel.getReds(reds);

View Full Code Here
   1: import java.awt.image.BufferedImage;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5: {
   6:     private static final String INVALID_COLOR_MODEL_MSG = "This builder works with IndexColorModel only. CurrentModel = ";
   7: 
   8:         ...
   9: 
  10:         IndexColorModel indexColorModel = getIndexColorModel();
  11: 
  12:         ...
  13:         indexColorModel.getReds(reds);

View Full Code Here
   1:     
   2:     IndexColorModel        model;
   3:     
   4:         ...
   5:     
   6:     public IndexColorModelSerializer(IndexColorModel m) {
   7:     model = m;
   8:         ...
   9:     
  10:     public IndexColorModel getModel() {
  11:     return model;
  12:         ...
  13:     byte[] blue_bytes = new byte[map_size];
  14:     model.getReds(red_bytes);

View Full Code Here
   1:     public void setColorModel(ColorModel model) {
   2:     if (model instanceof IndexColorModel && true) {
   3:         ...
   4:         IndexColorModel icm = (IndexColorModel) model;
   5:         models[0] = filterIndexColorModel(icm, false, false, 0);
   6:         ...
   7:     int mapsize = icm.getMapSize();
   8:     icm.getReds(r);
   9:     icm.getGreens(g);

View Full Code Here
   1:   {
   2:     if (model instanceof IndexColorModel && true)
   3:     {
   4:         ...
   5:       IndexColorModel icm = (IndexColorModel) model;
   6: 
   7:         ...
   8: 
   9:     icm.getReds(r);
  10:     icm.getGreens(g);

View Full Code Here

getTransparency

public int getTransparency()
Returns the transparency. Returns either OPAQUE, BITMASK, or TRANSLUCENT
Specified by:
getTransparency in interface Transparency
Overrides:
getTransparency in interface ColorModel
Returns:
the transparency of this IndexColorModel
Usages and Demos :

View More Examples of getTransparency()
   1: import java.awt.image.ComponentColorModel;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.SampleModel;
   4:         ...
   5:                     && defCCM.getColorSpace().equals(actualCCM.getColorSpace())
   6:                     && defCCM.getTransparency() == actualCCM.getTransparency() && defCCM
   7:                     .getTransferType() == actualCCM.getTransferType());
   8:         ...
   9:         }
  10:         if (defaultCM instanceof IndexColorModel
  11:         ...
  12:                 && actualCM instanceof IndexColorModel) {

View Full Code Here
   1: import java.awt.image.DirectColorModel;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.PackedColorModel;
   4:         ...
   5:         final ColorModel cm = image.getColorModel();
   6:         return (cm instanceof IndexColorModel) ? ((IndexColorModel) cm)
   7:                 .getTransparentPixel() : -1;
   8:         ...
   9:     public final boolean isIndexed() {
  10:         return image.getColorModel() instanceof IndexColorModel;
  11:     }
  12:         ...
  13:     public final boolean isTranslucent() {
  14:         return image.getColorModel().getTransparency() == Transparency.TRANSLUCENT;

View Full Code Here

getTransparentPixel

public final int getTransparentPixel()
Returns the index of a transparent pixel in this IndexColorModel or -1 if there is no pixel with an alpha value of 0. If a transparent pixel was explicitly specified in one of the constructors by its index, then that index will be preferred, otherwise, the index of any pixel which happens to be fully transparent may be returned.
Returns:
the index of a transparent pixel in this IndexColorModel object, or -1 if there is no such pixel
Usages and Demos :

View More Examples of getTransparentPixel()
   1:     
   2:     IndexColorModel        model;
   3:     
   4:         ...
   5:     
   6:     public IndexColorModelSerializer(IndexColorModel m) {
   7:     model = m;
   8:         ...
   9:     
  10:     public IndexColorModel getModel() {
  11:     return model;
  12:         ...
  13:     
  14:     if ( model.getTransparentPixel() >= 0 ) {

View Full Code Here
   1: import java.awt.image.ComponentColorModel;
   2: import java.awt.image.IndexColorModel;
   3: import java.awt.image.SampleModel;
   4:         ...
   5:         }
   6:         if (defaultCM instanceof IndexColorModel
   7:         ...
   8:                 && actualCM instanceof IndexColorModel) {
   9:             final IndexColorModel defICM = (IndexColorModel) defaultCM, actualICM = (IndexColorModel) actualCM;
  10:         ...
  11:                     || defICM.getTransferType() != actualICM.getTransferType()
  12:                     || defICM.getTransparentPixel() != actualICM

View Full Code Here

getValidPixels

public BigInteger getValidPixels()
Returns a BigInteger that indicates the valid/invalid pixels in the colormap. A bit is valid if the BigInteger value at that index is set, and is invalid if the BigInteger value at that index is not set. The only valid ranges to query in the BigInteger are between 0 and the map size.
Returns:
a BigInteger indicating the valid/invalid pixels.

isCompatibleRaster

public boolean isCompatibleRaster(Raster raster)
Returns true if raster is compatible with this ColorModel or false if it is not compatible with this ColorModel.
Overrides:
isCompatibleRaster in interface ColorModel
Parameters:
raster - the Raster object to test for compatibility
Returns:
true if raster is compatible with this ColorModel; false otherwise.

isCompatibleSampleModel

public boolean isCompatibleSampleModel(SampleModel sm)
Checks if the specified SampleModel is compatible with this ColorModel. If sm is null, this method returns false.
Overrides:
isCompatibleSampleModel in interface ColorModel
Parameters:
sm - the specified SampleModel, or null
Returns:
true if the specified SampleModel is compatible with this ColorModel; false otherwise.
See Also:
SampleModel

isValid

public boolean isValid()
Returns whether or not all of the pixels are valid.
Returns:
true if all pixels are valid; false otherwise.

isValid

public boolean isValid(int pixel)
Returns whether or not the pixel is valid.
Parameters:
pixel - the specified pixel value
Returns:
true if pixel is valid; false otherwise.

toString

public String toString()
Returns the String representation of the contents of this ColorModelobject.
Overrides:
toString in interface ColorModel
Returns:
a String representing the contents of this ColorModel object.