May 23

The PixelGrabber can be used to get a ColorModel instance that has a method to tell if alpha is supported. You just need to load a single pixel from the image to get the ColorModel.

PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
pg.grabPixels();
boolean hasAlpha = pg.getColorModel().hasAlpha();

written by objects \\ tags: , , ,

May 23

The BufferedImage’s ColorModel has a method that returns whether it supports alpha.


boolean hasAlpha = bufferedImage.getColorModel().hasAlpha();

written by objects \\ tags: ,