Per the contributor doc - added my name. Noticed urraka also did some work here, so hopefully didn't step on any toes.

- Fix an issue where the spec of the gif for restore to previous uses code 3, not 4.
- To get results that worked - made an assumption that "clear to background" meant "revert back to what was there before I drew", where mode 1 would revert back to the previous frame [slightly different].  If I clear to background color instead, I ended up with large opaque squares in gifs that changes their transparent colour each frame.
- Background color is supposed to be used only for pixels not rendered by the image, so took that to mean it only really affected the previous frame, or potentially any frame that used full disposal.  Since background color is allowed to be unspecified this is what lead me to believe I shouldn't use it for disposal.
- Oh, also upped the codes table to 8192 as 4096 ended up being too small for a few of my test cases.

Full disclaimer - I only read through the GIF format for this contribution, so competly could be misinterpreting the spec - but this gave me reuslts that matched Chrome.
This commit is contained in:
Chris Forseth 2017-11-27 23:06:53 -06:00
parent 87a3143fb4
commit 28c28b0bd2
1 changed files with 3 additions and 3 deletions

View File

@ -74,7 +74,7 @@ RECENT REVISION HISTORY:
Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip) Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip)
Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD) Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD)
github:urraka (animated gif) Junggon Kim (PNM comments) github:urraka (animated gif) Junggon Kim (PNM comments)
Daniel Gibson (16-bit TGA) github:tocchan (animated gif) Daniel Gibson (16-bit TGA)
socks-the-fox (16-bit PNG) socks-the-fox (16-bit PNG)
Jeremy Sawicki (handle all ImageNet JPGs) Jeremy Sawicki (handle all ImageNet JPGs)
Optimizations & bugfixes Optimizations & bugfixes
@ -6313,7 +6313,7 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i
dispose = 2; // if I don't have an image to revert back to, default to the old background dispose = 2; // if I don't have an image to revert back to, default to the old background
} }
if (dispose == 4) { // use previous graphic if (dispose == 3) { // use previous graphic
for (pi = 0; pi < pcount; ++pi) { for (pi = 0; pi < pcount; ++pi) {
if (g->history[pi]) { if (g->history[pi]) {
memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 ); memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 );
@ -6329,7 +6329,7 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i
} else { } else {
// This is a non-disposal case eithe way, so just // This is a non-disposal case eithe way, so just
// leave the pixels as is, and they will become the new background // leave the pixels as is, and they will become the new background
// 1: do not dispose? Same as 4? // 1: do not dispose
// 0: not specified. // 0: not specified.
} }