![]() |
The Java Developers Almanac 1.4 |
|
e663. Getting the Transparent Pixel and Number of Colors Used in a GIF ImageAIndexColorModel is used to represent the color table of a GIF
image.
// Get GIF image
Image image = new ImageIcon("image.gif").getImage();
// Get the color model; this method is implemented in
// e662 Getting the Color Model of an Image
IndexColorModel colorModel = (IndexColorModel)getColorModel(image);
// Get transparent pixel
int trans = colorModel.getTransparentPixel();
if (trans == -1) {
// There is no transparent pixel
}
// Get the number of colors
int numColors = colorModel.getMapSize();
e661. Determining If an Image Has Transparent Pixels e662. Getting the Color Model of an Image e664. Getting a Sub-Image of an Image e665. Filtering the RGB Values in an Image
© 2002 Addison-Wesley. |