Return to Snippet

Revision: 4947
at January 30, 2008 07:51 by ILoveBeer


Initial Code
public static byte[] bufferedImageToByteArray(BufferedImage img) throws ImageFormatException, IOException{
		ByteArrayOutputStream os = new ByteArrayOutputStream();
		JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);
		encoder.encode(img);
		return os.toByteArray();	
	}

Initial URL

                                

Initial Description
i use it so save bufferedImages into a DB as Blob

Initial Title
Convert a BufferedImage to a Byte Array as JPEG

Initial Tags
array

Initial Language
Java