Open-Imaging icon indicating copy to clipboard operation
Open-Imaging copied to clipboard

Not all GIFs start with a clear code

Open MarkJeronimus opened this issue 7 years ago • 2 comments

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.

MarkJeronimus avatar Nov 14 '17 20:11 MarkJeronimus

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

MarkJeronimus avatar Nov 14 '17 20:11 MarkJeronimus

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

MarkJeronimus avatar Nov 16 '17 19:11 MarkJeronimus