Java图片处理坑:gif文件读取ArrayIndexOutOfBoundsException: 4096

           在做图片处理库simpleImageTool时,运行还算正常,最近遇到个文件读取就挂掉,看到日志如下:

java.lang.ArrayIndexOutOfBoundsException: 4096

	at com.sun.imageio.plugins.gif.GIFImageReader.read(GIFImageReader.java:958)
	at javax.imageio.ImageIO.read(ImageIO.java:1448)
	at javax.imageio.ImageIO.read(ImageIO.java:1352)
	at clive.hua.app.simpleImageTool.SimpleImageToolTest.test(SimpleImageToolTest.java:15)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at junit.framework.TestCase.runTest(TestCase.java:176)
	at junit.framework.TestCase.runBare(TestCase.java:141)
	at junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit.framework.TestResult.run(TestResult.java:125)
	at junit.framework.TestCase.run(TestCase.java:129)
	at junit.framework.TestSuite.runTest(TestSuite.java:252)
	at junit.framework.TestSuite.run(TestSuite.java:247)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

               以前读取就是用ImageIo.read( )读取没有遇到没问题,最近遇到有的文件就抛上面的异常,最后发现是jdk的Image库的问题,很多人从1.6就提出了到现在1.8还是依然存在问题,没办法只有用gif解码自己解析才得以解决问题。也研究了几个gif得解码库,都可以很好的避免这个异常。但是gif解码存在不部分解码是花的,或者错帧。

GifDecoder :https://github.com/DhyanB/Open-Imaging/blob/master/src/main/java/at/dhyan/open_imaging/GifDecoder.java

Kevin Weiner's GifDecoder  https://github.com/DhyanB/Open-Imaging/blob/master/src/main/java/com/fmsware/GifDecoder.java

没有更多推荐了,返回首页