We can save a BufferImage object using write method of the ImageIO class. Firstly, we import the necessary class,
import javax.imageio.ImageIO;
The write method is like this:
public static boolean write(RenderedImage im,
String formatName,
File output)
throws IOException
As you can see, im is the RenderedImage to be written, formatName is the String which tells us the format (i.e png or jpg) and output is the file object to be written to. An example usage of the method for PNG file format shown below:
No comments:
Post a Comment