当试图使用阿帕奇-桑塞兰共产主义共产主义(Sanselan)来装载一个用包装压缩压缩压缩压缩的TIFF时,框外的ArrayIndex outsout ofboundsExpection。
守则:
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)
我试图分析这个问题,但我迷路了...任何方向都会很有帮助。