|
Oct
30
|
Create a ByteArrayInputStream from your byte array and then use ImageIO class to read image from that stream.
InputStream in = new ByteArrayInputStream(bytearray); BufferedImage image = ImageIO.read(in);
One Ping to “How do I read an image from a byte array in Java?”
3 Responses to “How do I read an image from a byte array in Java?”
-
djerry Says:
May 9th, 2009 at 3:15 pmthis is really nice, been searching for it for quite a while
all i saw where image from int[] arrays, but as i work with audio as well, i need byte[] arrays, so this is best way to do it, nice
-
IsraUC3M Says:
November 27th, 2010 at 7:03 amMAN YOU SAVED MY LIFE!!!
Thanks a lot for this snippet!
-
Namrata Says:
January 19th, 2012 at 5:54 pmHey,
This solution is worked well but when try to use same at google app engine, I’m not able to do.
Google app engine doesn’t support BufferedImage or ImageIO
I’m wondering about how it could be implemented.
you can find the whitelist of GAE for JAVA at http://code.google.com/appengine/docs/java/jrewhitelist.htmlI’m having a webservice on which the image is passed as byte array from web client.
Could you please suggest any way. Thanks in advance.
Regards,
Namrata Shah



May 29th, 2010 at 10:32 pm
[...] How do I read an image from a byte array in Java? | web development helpdesk [...]