java 用java读取jpeg2000文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2662916/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 22:16:13  来源:igfitidea点击:

read jpeg2000 files in java

javajpeg2000

提问by pedrofernandes

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

我有一个使用byte[]包含图像 jpeg2000 字节的代码。我想在jLabel组件中显示这个怎么做?任何人都有想法或代码要做?

回答by Hyman

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 JPG2000decoder isn't supplied with standard SDK, you should head here(Java Advanced Imaging) and use the right decoder for that format..

JPG2000解码器未随标准 SDK 提供,您应该前往此处(Java Advanced Imaging) 并为该格式使用正确的解码器。

回答by Fred F

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

显然,对 jpeg2000 / ( .jp2 ) 文件的支持已从 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.

通过卸载 JAI 1.1.3 并安装旧版本 1.1,我现在将要读取 .jp2 文件并且不再看到空指针。

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

1.1 版在此处可用。 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

版本 1.1 列出了用于 - g3fax g4fac jiio jp2k jpeg 和 png 的编解码器

回答by NoUserException

The only options I know are all based on jj2000.

我知道的唯一选项都是基于jj2000的。

jai-imageio-coreprovides support through an additional third-party module:

jai-imageio-core通过额外的第三方模块提供支持:

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

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

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

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.

它将自己注册到 ImageIO,然后您就可以像读取任何 png、bmp 或 jpeg 一样读取 jpeg2000 文件。

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

尽管 jj2000 本身是一个选项,但 api 并不是为日常使用而设计的。

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

其他选项包括JMRTD,它为jj2000提供自己的包装,或商业产品JDeli