Krolyxon
Commit 3e25238

Branches

Refs →

nsxiv3e25238

Fixed handling of gif disposal method (issue #23)

Author
Bert Münnich
Date
2011-10-17 18:39 +0200
Parent
55da6fb
Commit
3e2523818b2420a86d71ac7c908ddcbb800abd38

+9 −3

2 files changed

  1. M Makefile +1 −1
  2. M image.c +8 −2
M Makefile View
@@ -1,4 +1,4 @@
1−VERSION = git-20111016
1+VERSION = git-20111017
22
33 CC = gcc
44 CFLAGS = -ansi -Wall -pedantic -O2
M image.c View
@@ -133,6 +133,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) {
133133 Imlib_Image *im;
134134 int i, j, bg, r, g, b;
135135 int x, y, w, h, sw, sh;
136+ int px, py, pw, ph;
136137 int intoffset[] = { 0, 4, 2, 1 };
137138 int intjump[] = { 8, 8, 4, 2 };
138139 int transp = -1;
@@ -156,6 +157,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) {
156157 bg = gif->SBackGroundColor;
157158 sw = gif->SWidth;
158159 sh = gif->SHeight;
160+ px = py = pw = ph = 0;
159161
160162 do {
161163 if (DGifGetRecordType(gif, &rec) == GIF_ERROR) {
@@ -218,10 +220,13 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) {
218220 if (i < y || i >= y + h || j < x || j >= x + w ||
219221 rows[i-y][j-x] == transp)
220222 {
221− if (prev_disposal != 2 && prev_frame != NULL)
223+ if (prev_frame != NULL && (prev_disposal != 2 ||
224+ i < py || i >= py + ph || j < px || j >= px + pw))
225+ {
222226 *ptr = prev_frame[i * sw + j];
223− else
227+ } else {
224228 *ptr = bgpixel;
229+ }
225230 } else {
226231 r = cmap->Colors[rows[i-y][j-x]].Red;
227232 g = cmap->Colors[rows[i-y][j-x]].Green;
@@ -252,6 +257,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) {
252257 if (disposal != 3)
253258 prev_frame = imlib_image_get_data_for_reading_only();
254259 prev_disposal = disposal;
260+ px = x, py = y, pw = w, ph = h;
255261
256262 if (img->multi.cnt == img->multi.cap) {
257263 img->multi.cap *= 2;