Return to Snippet

Revision: 9705
at November 18, 2008 07:46 by roock


Initial Code
public String store(Image image, String fileType) throws IOException {
		File imageDir = createDir(IMAGE_DIR);
		String imageFileName = generateFilenameFromTimestamp(null, new Date(),
				fileType);
		BufferedImage bufferedImage = new BufferedImage(image.getWidth(null),
				image.getHeight(null), BufferedImage.TYPE_INT_RGB);
		Graphics2D g2 = bufferedImage.createGraphics();
		g2.drawImage(image, null, null);
		File imageFile = new File(imageDir, imageFileName);
		ImageIO.write(bufferedImage, fileType, imageFile);

		return imageFile.getPath();
	}

Initial URL

                                

Initial Description

                                

Initial Title
Store Image to File

Initial Tags
image, file

Initial Language
Java