Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

create ImageIcon from bytes[], not from file

 
Brian Tarbox
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to create an image icon, but not from a jpg or gif file. Rather, I have a 2d array of bytes that I want to display on a canvas.
ImageIcon has a constructor that takes byte[] but only if that array was "read from an image file containing a supported image format".
Is there a way to do this?
Brian Tarbox
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, where did u get the 2D array of bytes? Is it sure that the array you have represents a certain kind of ImageIcon? If not, even tough we construct an ImageIcon using that array, we will not be able to see the icon...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic