e661. 确定图像中是否有透明像素
Posted borter
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了e661. 确定图像中是否有透明像素相关的知识,希望对你有一定的参考价值。
// This method returns true if the specified image has transparent pixels public static boolean hasAlpha(Image image) { // If buffered image, the color model is readily available if (image instanceof BufferedImage) { BufferedImage bimage = (BufferedImage)image; return bimage.getColorModel().hasAlpha(); } // Use a pixel grabber to retrieve the image‘s color model; // grabbing a single pixel is usually sufficient PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false); try { pg.grabPixels(); } catch (InterruptedException e) { } // Get the image‘s color model ColorModel cm = pg.getColorModel(); return cm.hasAlpha(); }
Related Examples |
以上是关于e661. 确定图像中是否有透明像素的主要内容,如果未能解决你的问题,请参考以下文章