From 28c28b0bd23534f405938e29505fb47780fadd3d Mon Sep 17 00:00:00 2001 From: Chris Forseth Date: Mon, 27 Nov 2017 23:06:53 -0600 Subject: [PATCH] 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. --- stb_image.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stb_image.h b/stb_image.h index aa25fb2..167904f 100644 --- a/stb_image.h +++ b/stb_image.h @@ -74,7 +74,7 @@ RECENT REVISION HISTORY: Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip) Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD) 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) Jeremy Sawicki (handle all ImageNet JPGs) 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 } - if (dispose == 4) { // use previous graphic + if (dispose == 3) { // use previous graphic for (pi = 0; pi < pcount; ++pi) { if (g->history[pi]) { 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 { // This is a non-disposal case eithe way, so just // 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. }