Java examples for 2D Graphics:BufferedImage Color
BufferedImage convert To ARGB
//package com.java2s; import java.awt.image.BufferedImage; import java.awt.image.ColorConvertOp; public class Main { public static BufferedImage convertToARGB(BufferedImage src) { BufferedImage dest = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_ARGB); ColorConvertOp cco = new ColorConvertOp(src.getColorModel() .getColorSpace(), dest.getColorModel().getColorSpace(), null);/*from w w w . j a v a 2s . co m*/ cco.filter(src, dest); System.out.println("Number of bands by pixel :" + dest.getRaster().getNumBands()); System.out.println("Number of data elements :" + dest.getRaster().getNumDataElements()); System.out.println("Transfer type raster :" + dest.getRaster().getTransferType()); System.out.println("Transfer type dataBuffer :" + dest.getRaster().getDataBuffer().getDataType()); System.out.println("Transfer type colorModel :" + dest.getColorModel().getTransferType()); System.out.println("Number of bits by pixel :" + dest.getColorModel().getPixelSize()); System.out.println("alpha premultiplied :" + dest.getColorModel().isAlphaPremultiplied()); System.out .println("isCompatibleRaster :" + dest.getColorModel().isCompatibleRaster( dest.getRaster())); System.out.println("Color space type :" + dest.getColorModel().getColorSpace().getType()); System.out.println("Sample model :" + dest.getSampleModel().getClass()); System.out.println("Color model class :" + dest.getColorModel().getClass()); return dest; } }