List of usage examples for java.awt.image PixelGrabber PixelGrabber
public PixelGrabber(Image img, int x, int y, int w, int h, boolean forceRGB)
From source file:net.pms.medialibrary.commons.helpers.FileImportHelper.java
private 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(); }/* w w w . j a va 2 s . c o m*/ // 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(); }
From source file:lucee.runtime.img.Image.java
/** * This method returns true if the specified image has transparent pixels * @param image//from w w w .ja va2 s .co m * @return */ public static boolean hasAlpha(java.awt.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(); }