File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Convert image to byte[] and viceversa Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Convert image to byte[] and viceversa" Watch "Convert image to byte[] and viceversa" New topic
Author

Convert image to byte[] and viceversa

Adriano Bellavita
Ranch Hand

Joined: Mar 11, 2010
Posts: 37
I use this method to convert an image to an array of byte



When I try to reconvert the byte array into an Image by this code

PS: a is the byte array, y is an int array obtained by converting byte array like this





but the final image I found on the desktop is not the real image!!! It has a black background with some vertical colored lines.

Where is my error? In the first or in the second part?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I thought the byte data from a read was just the image data--does it include all the metadata included in the file format?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Too difficult for "beginning"; moving thread.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Convert image to byte[] and viceversa
 
Similar Threads
java.lang.IllegalArgumentException: im == null!
Servlet request object input stream time out
Image corruption
java.io.IOException at out.write()
Image smoothing