0
我想在java中將jp2圖像讀入BufferedImage中。我安裝了Java Advanced Imaging JAI。這是我的代碼:如何在Java中將jp2圖像讀入BufferedImage中
RenderedOp img = JAI.create("FileLoad", "/home/dhoha/Downloads/BreastCancer.jp2");
BufferedImage image = img.getAsBufferedImage();
不過,我得到以下錯誤:
Exception in thread "main" java.lang.RuntimeException: - Unable to render RenderedOp for this operation.
at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:827)
at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:867)
at javax.media.jai.RenderedOp.getColorModel(RenderedOp.java:2242)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2498)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2546)
at testJai.test.main(test.java:19)
我不明白爲什麼JAI庫是無法讀取的JP2圖像儘管這個操作與BMP可行圖片..
任何提示請???
你有哪些JAI的版本?閱讀本文http://stackoverflow.com/a/13167748/1737819 – Willmore 2015-01-06 10:37:36
是的,我已經安裝了舊版本的JAI 1.1,因爲JAI 1.3不支持jpeg 2000圖像......而目前我正面臨着這個問題。任何提示? – didowa 2015-01-06 10:44:20
請輸入javax.imageio.ImageIO; import java.util.Arrays; 公共類的ImageWriter { \t公共靜態無效的主要(字串[] args) \t { \t \t的System.out.println(Arrays.deepToString(ImageIO.getReaderFormatNames())); \t \t System.out.println(Arrays.deepToString(ImageIO.getReaderFileSuffixes())); \t \t System.out.println(Arrays.deepToString(ImageIO.getReaderMIMETypes())); \t} }是否列出jp2作爲文件類型? – Willmore 2015-01-06 11:53:05