square / gifencoder

A pure Java library implementing the GIF89a specification. Suitable for use on Android.
Apache License 2.0
664 stars 75 forks source link

Refactor code related to the LZW minimum code size #16

Closed dlubarov closed 5 years ago

dlubarov commented 5 years ago

We were deriving the minimum code size from the number of colors in the LZW code table, which is sort of backwards. The spec defines the "clear" code's value (and implicitly, the number of colors in the LZW code table) based on the minimum code size.

I also made some tweaks to emphasize that the number of colors in the LZW code table may not match the color table size, as @rendaw pointed out in #14. The former quantity is now just a local variable in defaultCodeTable, so it's more contained. The latter quantity I renamed to colorTableSize.