I have a BufferedImage object and I want to encode it to the BMP format and save it to disk.
How do I do this?
In JPEG
it's ok:
BufferedImage img; //here is an image ready to be recorded into the hard disk
FileOutputStream fout = new FileOutputStream("image.jpg");
JPEGImageEncoder jencoder = JPEGCodec.createJPEGEncoder(fout);
JPEGEncodeParam enParam = jencoder.getDefaultJPEGEncodeParam(img);
enParam.setQuality(1.0F, true);
jencoder.setJPEGEncodeParam(enParam);
jencoder.encode(img);
fout.close();
BufferedImage
isBufferedImage.TYPE_INT_RGB
and notBufferedImage.TYPE_INT_ARGB
– Barbitone