Thursday, 9 January 2014

Convert BufferedImage To ByteBuffer

In applet its very simple to do this

BufferedImage originalImage = ImageIO.read(new File("c:\\image\\mypic.jpg"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write( originalImage, "jpg", baos );
baos.flush();
byte[] imageInByte = baos.toByteArray();
baos.close()
ByteBuffer buf = ByteBuffer.wrap(imageInByte);

1 comment:

Cristian Barreto said...

Excelent! work for me!!!!