1. 程式人生 > >e663. 在gif圖像中獲取透明和色彩的數量

e663. 在gif圖像中獲取透明和色彩的數量

pac order mco The table adding ans num bgcolor

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
    // e662 取的圖像的色彩模型
    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();

Related Examples

e663. 在gif圖像中獲取透明和色彩的數量