e663. 在gif图像中获取透明和色彩的数量

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
posted @ 2018-09-02 21:48  borter  阅读(120)  评论(0编辑  收藏  举报