writing an image file from an Image object
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Java_THuG
Posted On:   Saturday, May 15, 2004 12:56 PM


how can i write an image file (.jpg for example) when am having the Image Object that contains the image data ??

Thanks in Advance

Re: writing an image file from an Image object

Posted By:   olivier_saugeon  
Posted On:   Wednesday, June 23, 2004 03:02 AM

You should use the javax.imageio.ImageIO Class :

ImageIO.write( myImage, theImageFormat, theOutputStream);

myImage should be a BufferedImage,

theImageFormat should be "JPG" or "PNG",

theOutputStream sould be an OutputStream.



an example :


// read an image form myImage.png file
BufferedImage bufImg = new IconImage(myImage.png).getImage;
// prepare an output stream to newImage.png file
OutputStream out = new FileOutputStream(new File(newImage.png));
// write the image to the new file
ImageIO.write(bufImg, "PNG", out);
About | Sitemap | Contact