Apache-Commons Sanselan AIOOBE在解压缩PackBits TIFF时

时间:2012-05-22 20:06:24

标签: java apache-commons indexoutofboundsexception

在尝试使用Apache-Commons Sanselan加载使用PackBits压缩压缩的TIFF时,开箱即用的ArrayIndexOutOfBoundsException。

代码:

import org.apache.sanselan.*;

public class TIFFHandler {
    public static Image loadTIFF(String fileName) throws ImageReadException, IOException {
        File imageFile = new File(fileName);
        BufferedImage bi = Sanselan.getBufferedImage(imageFile);
        return bi;
    }

    public static void main(String[] args) throws IOException, ImageReadException {
        String TIFFFILE = "test_image.tif";
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        JPanel panel = new JPanel();
        BufferedImage bi = (BufferedImage) loadTIFF(TIFFFILE);
        ImageIcon ii = new ImageIcon(bi);
        JLabel lbl = new JLabel(ii);
        panel.add(lbl);
        frame.setVisible(true);
    }
}

堆栈追踪:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 426
at org.apache.sanselan.common.PackBits.decompress(PackBits.java:55)
at org.apache.sanselan.formats.tiff.datareaders.DataReader.decompress(DataReader.java:127)
at org.apache.sanselan.formats.tiff.datareaders.DataReaderStrips.readImageData(DataReaderStrips.java:96)
at org.apache.sanselan.formats.tiff.TiffImageParser.getBufferedImage(TiffImageParser.java:505)
at org.apache.sanselan.formats.tiff.TiffDirectory.getTiffImage(TiffDirectory.java:163)
at org.apache.sanselan.formats.tiff.TiffImageParser.getBufferedImage(TiffImageParser.java:441)
at org.apache.sanselan.Sanselan.getBufferedImage(Sanselan.java:1264)
at org.apache.sanselan.Sanselan.getBufferedImage(Sanselan.java:1255)
at TIFFHandler.loadTIFF(FieldSheetHandler.java:42)
at TIFFHandler.main(FieldSheetHandler.java:90)

我试图对这个问题进行分析,但我很遗憾......任何方向都会有所帮助。 TIFF图像是a **中的痛苦。

1 个答案:

答案 0 :(得分:1)

您可以从Apache快照存储库中尝试更新版本的Commons Imaging。 Javadoc尚未在线,您必须按checking out the code from SVN构建并运行mvn javadoc:javadoc

如果您发现更多问题或想要建议改进,可以在JIRA中提交。如果您对API的使用有疑问,开发人员也很乐意为您提供帮助。他们在mailing list上等着你。