• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to convert image to bytearray in MIDlet  RSS feed

 
Theeranit Pongtongmuang
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I'm very new for Java I/0.

I want to convert Image object to byte array (byte[])
This is my code for creating Image.


Image myImage =null;
try {
myImage = Image.createImage("/myImage.png");
} catch (IOException ex) {
ex.printStackTrace();
}

How can I convert "myImage" to byte[] with Java I/0

Please could you give me a good suggestion and code snippet.

Thanks a lot.
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you use the combination of FileInputStream and ByteArrayInputStream to get the byte array? With that you don't need to convert Image to byte array anymore.
 
Theeranit Pongtongmuang
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your suggestion.

I get an idea to solve this problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!