Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Byte array to image file  RSS feed

 
Kat Brown
Greenhorn
Posts: 2
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using the following line to create an image from a byte array.



When I run the code though I get a Runtime Exception that says: "New BMP version no implemented yet"

The byte array is being create with raw image data. For testing purpose the raw data is saved in a text file and read in from there. I got the raw data from a test image that is a .bmp file.

Does anyone have any idea what could be going on.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those classes apparently don't support BMP as a format, or at least not the kind of BMP you tried to use.

(That would likely be because BMP is a proprietary format which isn't widely used, especially in web-based applications where Java was originally targeted.)
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Java version are you using? I read an image from an existing JPEG file, then used the same code to write it, and it succeeded. I tried with both Java 6 and Java 7.
 
Kat Brown
Greenhorn
Posts: 2
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've resolved this issue, it seems that for some reason the data in the text file is corrupt. When I take an image file and make it into a byte array with java it works fine. Ultimately I should be getting data from a serial port so I'm sure that data won't be corrupted.
 
John Jai
Rancher
Posts: 1776
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to Javaranch, Kat Brown
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!