Initial port from java
- only changes are comments, formatting, a bit of renaming, and rewriting the pixel bytes loading
Initial refactor
Forgot to rename the file
Forgot to rename the file
Enum-ify frame disposal method
Take out a couple things that don't need to be named vars
The main thing that's refactored here is removing "usedEntry"
- the color table contains only the actually used colors (and padding)
- this required exposing more of the quantizer's data structure opinions to the calling code, but I'll tackle that later
The color table byte count is often greater than 256
documentation
optimization part one
- identify duplicate frames and rewrite the previous Graphic Control Extension block with an extended frame duration instead
- this safely builds on the fact that going back and changing a frame delay doesn't change the *length* of the GCE block, so nothing after it is overwritten
- also setting up a composite pixel byte array, which while not strictly necessary for this optimization, will be handly later
optimization part 2
- erase bits of the current frame using the transparency color, if they're the same as what would aready be showing
- now we actually make use of the composite array
documentation, usings
Write out padding regardless of length
- previous code wouldn't write out the padding for i=0
Fix transparent color bleed to quantized colors
- keep track of the normal nontransparent pixels, and only quantize those
- when finding color indexes for each pixel, ignore the quantizer's result and manually write out the transparent color
- getClosestPaletteIndex is gone: we can now directly store the transparent color's color table index in the Frame object, and don't need to scan through to find a closest match afterward.
Need to reserve a slot in the color table for the transparent color
- before, if we were excluding the transparent color from the quantizer's input, it may very well generate 256 actually used colors
- then there'd be no opportunity to write the transparent color to the color table
- with this change, limit the quantizer's output to 255 if we're planning on writing the transparent color as well
- although, the quantizer has to be hacked a bit to work with potentially only 255 colors
a bit more explanation
Flatten this section out a bit
Flatten this a bit, too
AutoTransparency fixes
- make sure to still record opaque pixels even when there's no change
- indexed location is color index not byte index
- if we didn't end up writing the transparency color to the color table, reset it (fix now, relevant later)
Add support for variable sized frames with ClipFrame optimization