Posted By

ILoveBeer on 01/30/08


Tagged

array byte jpeg BufferedImage


Versions (?)

Convert a BufferedImage to a Byte Array as JPEG


 / Published in: Java
 

i use it so save bufferedImages into a DB as Blob

  1. public static byte[] bufferedImageToByteArray(BufferedImage img) throws ImageFormatException, IOException{
  2. JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);
  3. encoder.encode(img);
  4. return os.toByteArray();
  5. }

Report this snippet  

You need to login to post a comment.