Java - converting a byte[] array back to BufferedImage
By bytecracker
@bytecracker (16)
Bulgaria
January 22, 2013 6:31am CST
Okay, so this is the problem : I need to convert a BufferedImage into something I can then easily convert to JavaScript Object Notation(JSON). Well, it turns out the easiest way is to, first convert that BufferedImage into a byte[] array, serialize it with Gson JSON library, made by google, then, when I need it back, retrieve fast the JSON string and convert it back to a byte[] array and then to a BufferedImage.
So, converting a BufferedImage into a byte[] is pretty easy, using a FileOuputStream, but I'm not sure about the opposite action. Any recommendations?
1 response
@owlwings (43910)
• Cambridge, England
22 Jan 13
There are plenty of pages which describe this exactly. For example, a simple search found this, which answers your question in detail: http://www.mkyong.com/java/how-to-convert-byte-to-bufferedimage-in-java/
You are not likely to get good answers in MyLot:
1) Because there are not too many programmers here
2) Because MyLot is a DISCUSSION site and this sort of question is not considered a discussion.
If you wish to ask questions about programming, I suggest that you join a forum which specialises in Java.