Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Convert image to byte[] and viceversa

 
Adriano Bellavita
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult for "beginning"; moving thread.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic