jeudi 5 mars 2015

How to convert a Type_Byte_Binary BufferedImage with Alpha to an TYPE_4BYTE_ABGR



Im using the code



BufferedImage imgIn = ImageIO.read(is);

BufferedImage image;
if (imgIn.getType() != BufferedImage.TYPE_BYTE_INDEXED) {
image = new BufferedImage(imgIn.getWidth(), imgIn.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
ColorConvertOp cco = new ColorConvertOp(imgIn.getColorModel()
.getColorSpace(), image.getColorModel().getColorSpace(), null);
cco.filter(imgIn, image);
} else {
image = imgIn;
}


When I'm pulling in an image with a Bit Depth of 4 it makes the imgIn a Type_Byte_Binary. When It gets converted to Type_4Byte_ABGR anything with partial transparency changes color and loses all alpha. Fully transparent pixels and Fully Opaque pixels remained unchanged.


Is there anything I can do to keep the partially transparent pixels from changing?


Thanks.




Aucun commentaire:

Enregistrer un commentaire