Getting the Transparent Pixel and Number of Colors Used in a GIF Image

A IndexColorModel 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 // 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();

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.