Saving a BufferedImage as a JPEG  
Author Message
michael.a.johnston





PostPosted: 2004-5-7 22:07:00 Top

java-programmer, Saving a BufferedImage as a JPEG I am saving a BufferedImage as a JPEG file under Windows XP.
I am using the JAI JPEGImageEncoder class.
The JPEG is saved as CMYK but I need RGB.
I cannot figure out how to get RGB. Any help?
 
Murray





PostPosted: 2004-5-7 22:50:00 Top

java-programmer >> Saving a BufferedImage as a JPEG
"Michael Johnston" <email***@***.com> wrote in message
news:email***@***.com...
> I am saving a BufferedImage as a JPEG file under Windows XP.
> I am using the JAI JPEGImageEncoder class.
> The JPEG is saved as CMYK but I need RGB.
> I cannot figure out how to get RGB. Any help?

Where is the BufferedImage coming from? If you're creating the object
yourself, try using INT_RGB imageType instead of the default ARGB.

image = new BufferedImage(x, y, BufferedImage.TYPE_INT_RGB);

It might also be worth trying this:

JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(image);
encoder.encode(img, param);