jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes convert binary data into jpg Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "convert binary data into jpg " Watch "convert binary data into jpg " New topic

convert binary data into jpg

Nitin Agarwal

Joined: Dec 15, 2005
Posts: 9

how to convert binary data into jpg image through java.
I have xml file which contain <Binary> element in which binary data of image is fill and through java swing we have to read it and display image in JFrame.

Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
I don't know what form the data has when you get it out of your XML document,
but you can use this method of javax.imageio.ImageIO:

public static BufferedImage read(InputStream input) throws IOExeption

If the XML API gives you a byte[] instead of an InputStream, there's
always ByteArrayInputStream.

There is no emoticon for what I am feeling!
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

However XML is a text format that does not permit arbitrary binary data, so if it contains bytes to make a JPG then those bytes must have been encoded in some way. You will have to decode them in the corresponding way, whatever that is. It is common to use Base64 encoding to put binary data into XML but that does not mean your binary data was encoded that way.
I agree. Here's the link: http://aspose.com/file-tools
subject: convert binary data into jpg
It's not a secret anymore!