Here you can find the source of encodeImage(BufferedImage bufferedImage, File file)
Parameter | Description |
---|---|
bufferedImage | the Buffered Image to be encoded |
file | the File to write to |
public static void encodeImage(BufferedImage bufferedImage, File file)
//package com.java2s; import javax.imageio.*; import javax.swing.*; import java.awt.image.BufferedImage; import java.io.*; public class Main { /**//from w ww .jav a 2 s . c o m * encodes as a .jpg a given BufferedImage * @param bufferedImage the Buffered Image to be encoded * @param file the File to write to */ public static void encodeImage(BufferedImage bufferedImage, File file) { try { // Save as JPEG ImageIO.write(bufferedImage, "jpg", file); } catch (IOException e) { JOptionPane.showMessageDialog(null, "Sorry, an error has occured : " + e); } // Create a buffered image in which to draw } }