package com.laxman.image; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import javax.imageio.ImageIO; public class ImageTest { public static void main(String[] args) { try { byte[] imageInByte; BufferedImage originalImage = ImageIO.read(new File( "c:/darksouls.jpg")); // convert BufferedImage to byte array ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(originalImage, "jpg", baos); baos.flush(); imageInByte = baos.toByteArray(); baos.close(); // convert byte array back to BufferedImage InputStream in = new ByteArrayInputStream(imageInByte); BufferedImage bImageFromConvert = ImageIO.read(in); ImageIO.write(bImageFromConvert, "jpg", new File( "c:/new-darksouls.jpg")); } catch (IOException e) { System.out.println(e.getMessage()); } } }
Tuesday, April 17, 2012
How to convert byte[] to BufferedImage in Java
Subscribe to:
Post Comments (Atom)
I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post I would like to read this
ReplyDeleteData Science training in Chennai
Data science training in Bangalore
Data science training in pune
Data science online training
Data Science Interview questions and answers
Data science training in bangalore
This comment has been removed by the author.
ReplyDeleteI have to voice my passion for your kindness giving support to those people that should have guidance on this important matter.
ReplyDeleteMCSE Training in chennai | mcse training class chennai
Thank you for this post. That's all I are able to say. You most absolutely have built this blog website into something special. You clearly know what you are working on, you have insured so many corners.thanks
ReplyDeleteData Science Training In Chennai
Data Science Online Training In Chennai
Data Science Training In Bangalore
Data Science Training In Hyderabad
Data Science Training In Coimbatore
Data Science Training
Data Science Online Training
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeleteoracle training in chennai
oracle training in porur
oracle dba training in chennai
oracle dba training in porur
ccna training in chennai
ccna training in porur
seo training in chennai
seo training in porur
Your work is very good and I appreciate you and hopping for some more informative posts
ReplyDeletedata scientist course in hyderabad
ReplyDeleteGreat to become visiting your weblog once more, it has been a very long time for me. Pleasantly this article i've been sat tight for such a long time. I will require this post to add up to my task in the school, and it has identical subject along with your review. Much appreciated, great offer. data science course in nagpur
Really an awesome blog, with informative and knowledgeable content. Thanks for sharing this blog with us. Keep sharing more stuff again.
ReplyDeleteData Science Online Course
Wonderful blog. I am delighted in perusing your articles. This is genuinely an incredible pursuit for me. I have bookmarked it and I am anticipating perusing new articles. Keep doing awesome!
ReplyDeletedata analytics training in hyderabad
The technological knowledge you shared in this post is quite beneficial for coming up with fresh ideas.
ReplyDeleteI also want to post this here , Java training institute in Noida