Krolyxon
Commit 4864f04

Branches

Refs →

nsxiv4864f04

Regard gif disposal method; fix bug #18

Author
Bert Münnich
Date
2011-10-11 20:28 +0200
Parent
71e61b1
Commit
4864f0445549d5d4da9afcc696312d6cb0886d40

+8 −6

2 files changed

  1. M Makefile +1 −1
  2. M image.c +7 −5
M Makefile View
@@ -1,4 +1,4 @@
1−VERSION = git-20110929
1+VERSION = git-20111011
22
33 CC = gcc
44 CFLAGS = -Wall -pedantic -O2
M image.c View
@@ -137,6 +137,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) {
137137 int intoffset[] = { 0, 4, 2, 1 };
138138 int intjump[] = { 8, 8, 4, 2 };
139139 int transp = -1;
140+ unsigned int disposal = 0, prev_disposal = 0;
140141 unsigned int delay = 0;
141142 bool err = false;
142143
@@ -178,8 +179,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) {
178179 if (delay)
179180 delay = MAX(delay, MIN_GIF_DELAY);
180181
181− /* TODO: handle disposal method, section 23.c.iv of
182− http://www.w3.org/Graphics/GIF/spec-gif89a.txt */
182+ disposal = (unsigned int) ext[1] >> 2 & 0x7;
183183 }
184184 ext = NULL;
185185 DGifGetExtensionNext(gif, &ext);
@@ -219,7 +219,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) {
219219 if (i < y || i >= y + h || j < x || j >= x + w ||
220220 rows[i-y][j-x] == transp)
221221 {
222− if (prev_frame != NULL)
222+ if (prev_disposal != 2 && prev_frame != NULL)
223223 *ptr = prev_frame[i * sw + j];
224224 else
225225 *ptr = bgpixel;
@@ -246,12 +246,14 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) {
246246 }
247247
248248 imlib_context_set_image(im);
249− prev_frame = imlib_image_get_data_for_reading_only();
250−
251249 imlib_image_set_format("gif");
252250 if (transp >= 0)
253251 imlib_image_set_has_alpha(1);
254252
253+ if (disposal != 3)
254+ prev_frame = imlib_image_get_data_for_reading_only();
255+ prev_disposal = disposal;
256+
255257 if (img->multi.cnt == img->multi.cap) {
256258 img->multi.cap *= 2;
257259 img->multi.frames = (img_frame_t*)