Save an image.
BufferedImage rendImage = null;
// Create a BufferedImage
if (image instanceof BufferedImage) {
rendImage = (BufferedImage) image;
} else {
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(image, 0);
tracker.waitForAll();
rendImage = new BufferedImage(image.getWidth(null), image.getHeight(null), 1);
Graphics g = rendImage.createGraphics();
g.drawImage(image, 0, 0, null);
}
// Write the image to the output stream
if ("image/jpeg".equals(mimeType)) {
JPEGImageEncoderImpl j = new JPEGImageEncoderImpl(os);
j.encode(rendImage);
}
else {
throw new IOException(Messages.getMessage("jpegOnly", mimeType));
}