Java examples for 2D Graphics:BufferedImage Pixel
This method returns true if the specified image has transparent pixels
import java.awt.Image; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.PixelGrabber; public class Main { public static boolean hasAlpha(Image image) { if (image instanceof BufferedImage) { BufferedImage bimage = (BufferedImage) image; return bimage.getColorModel().hasAlpha(); }//from www . j a va2 s .co m PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false); try { pg.grabPixels(); } catch (InterruptedException e) { } ColorModel cm = pg.getColorModel(); return cm.hasAlpha(); } }