You are viewing a plain text version of this content. The canonical link for it is here.
Posted to sanselan-dev@incubator.apache.org by David Greenspan <dg...@alum.mit.edu> on 2008/11/07 14:31:42 UTC

Bug: 1-bit GIFs are malformed (and fix)

Creating any 1-bit GIF, such as an opaque GIF with one or two colors,
produces strange results, for example when viewed in Firefox.  Some or
all of the pixels come out missing or black.

I'm no expert on the GIF format, but I traced the problem to what
seems to be a pretty clear violation of the spec -- the LZW "code
size" should never be less than 2 (per
http://www.w3.org/Graphics/GIF/spec-gif89a.txt, Appendix F).  I'm
satisfied by the following change to GifImageParser.java and plan to
use it for my application:

====
				int LZWMinimumCodeSize = colorTableScaleLessOne + 1;
				// TODO:
				// make
				// better
				// choice
				// here.
>>>>>>>>			if (LZWMinimumCodeSize < 2) LZWMinimumCodeSize = 2;
				bos.write(LZWMinimumCodeSize);
====

I hope this helps.  Sorry I didn't submit this through the
bug-tracking system; I couldn't figure out how to add a new issue.

Thanks,
David