read jpeg2000 files in java
Asked Answered
S

5

9

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?

Surfboarding answered 18/4, 2010 at 16:13 Comment(0)
E
4

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..

Eggleston answered 18/4, 2010 at 16:27 Comment(1)
I've downloaded the jai (from the java site, not from your link, because i can't find the jai file to download it) but, when i tried to use your way to read the image. I got the Null exception, i don't know why. even that i did add the jar files to my project(reference them).. so, what the solution for that ??Dugout
F
4

Apparently the support of jpeg2000 / ( .jp2 ) files has been removed from Java Advanced Imaging (JAI).

By un-installing JAI 1.1.3 and installing the older version 1.1, I'm now about to read .jp2 files and no longer see the null pointer.

Version 1.1 is available here. http://download.java.net/media/jai-imageio/builds/release/1.1/

Version 1.1 lists codec's for - g3fax g4fac jiio jp2k jpeg and png

Freeboard answered 31/10, 2012 at 21:32 Comment(2)
Link is dead, here is a new link to the oracle archive oracle.com/technetwork/java/javasebusiness/downloads/…Jordanjordana
Man this image format is a pain in the backRichert
G
2

The only options I know are all based on jj2000.

jai-imageio-core provides support through an additional third-party module:

https://github.com/stain/jai-imageio-core

https://github.com/jai-imageio/jai-imageio-jpeg2000

It'll register itself with ImageIO and you'll then be able to read jpeg2000 files as you would any png, bmp or jpeg.

Although jj2000 is in itself an option, the api is not designed for day-to-day use.

Other options include JMRTD, which provides its own wrapping for jj2000, or a commercial offering, JDeli.

Geneviegenevieve answered 13/5, 2013 at 22:40 Comment(1)
There is now another option (based on jj2000), from BFO: github.com/faceless2/jpeg2000Typecast
N
1

With the Java library imageio-openjpeg (Apache 2 license) you can use Jpeg2000 files (*.jp2) with the imageio API from Java. It is based on OpenJPEG (BSD license). Since 2015 is OpenJPEG the reference software of the Jpeg2000 standard.

If you want use it then you need both imageio-openjpeg and the OpenJPEG for your platform.

Norge answered 13/9, 2020 at 18:56 Comment(0)
R
0

This is the best project I could find until this day that supports JPEG2000/J2K images:

It also provides good documentation to use:

https://github.com/jai-imageio/jai-imageio-jpeg2000

Richert answered 9/6, 2023 at 15:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.