Open-Imaging
Open-Imaging copied to clipboard
Not all GIFs start with a clear code
While debugging some gifs that even Paint Shop Pro fails to render (but Windows, Firefox and Microsoft GIF Animator do read correctly) I found all of them had no clear code as the first code in each frame.
Removing line 202 fixed it.
bits.read(); // Skip leading clear code
However this breaks all other GIFs because now their clear code is interpreted as a color code. Need to investigate.
Some NSFW gifs without clear code: https://chan.sankakucomplex.com/post/show/227707 https://chan.sankakucomplex.com/post/show/249327 https://chan.sankakucomplex.com/post/show/280646
It may be a band-aid, but this fixed it for me:
GifDecoder.java:201
codes.clear(); // Init code table
int code = bits.read(); // Read first code
if (code == clearCode) { // Skip leading clear code
code = bits.read();
}
int[] pixels = tbl[code]; // Output pixel for first code