read jpeg2000 files in java

pedrofernandes picture pedrofernandes · Apr 18, 2010 · Viewed 12.7k times · Source

I have a code using a byte[] that contains a image jpeg2000 bytes. I want show this in jLabel component howto do this? Anyone have idea or code to do?

Answer

Jack picture Jack · Apr 18, 2010

You would do it in this way

Image img = ImageIO.read(new ByteArrayInputStream(imageBytes));
ImageIcon imgIcon = new ImageIcon(img);

JLabel label = new JLabel(imgIcon);

but the JPG2000 decoder isn't supplied with standard SDK, you should head here (Java Advanced Imaging) and use the right decoder for that format..