nsxiv3e25238
Fixed handling of gif disposal method (issue #23)
+9 −3
2 files changed
| @@ -1,4 +1,4 @@ | |||
| 1 | − | VERSION = git-20111016 | |
| 1 | + | VERSION = git-20111017 | |
| 2 | 2 | ||
| 3 | 3 | CC = gcc | |
| 4 | 4 | CFLAGS = -ansi -Wall -pedantic -O2 | |
| @@ -133,6 +133,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) { | |||
| 133 | 133 | Imlib_Image *im; | |
| 134 | 134 | int i, j, bg, r, g, b; | |
| 135 | 135 | int x, y, w, h, sw, sh; | |
| 136 | + | int px, py, pw, ph; | |
| 136 | 137 | int intoffset[] = { 0, 4, 2, 1 }; | |
| 137 | 138 | int intjump[] = { 8, 8, 4, 2 }; | |
| 138 | 139 | int transp = -1; | |
| @@ -156,6 +157,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) { | |||
| 156 | 157 | bg = gif->SBackGroundColor; | |
| 157 | 158 | sw = gif->SWidth; | |
| 158 | 159 | sh = gif->SHeight; | |
| 160 | + | px = py = pw = ph = 0; | |
| 159 | 161 | ||
| 160 | 162 | do { | |
| 161 | 163 | if (DGifGetRecordType(gif, &rec) == GIF_ERROR) { | |
| @@ -218,10 +220,13 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) { | |||
| 218 | 220 | if (i < y || i >= y + h || j < x || j >= x + w || | |
| 219 | 221 | rows[i-y][j-x] == transp) | |
| 220 | 222 | { | |
| 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 | + | { | |
| 222 | 226 | *ptr = prev_frame[i * sw + j]; | |
| 223 | − | else | |
| 227 | + | } else { | |
| 224 | 228 | *ptr = bgpixel; | |
| 229 | + | } | |
| 225 | 230 | } else { | |
| 226 | 231 | r = cmap->Colors[rows[i-y][j-x]].Red; | |
| 227 | 232 | g = cmap->Colors[rows[i-y][j-x]].Green; | |
| @@ -252,6 +257,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) { | |||
| 252 | 257 | if (disposal != 3) | |
| 253 | 258 | prev_frame = imlib_image_get_data_for_reading_only(); | |
| 254 | 259 | prev_disposal = disposal; | |
| 260 | + | px = x, py = y, pw = w, ph = h; | |
| 255 | 261 | ||
| 256 | 262 | if (img->multi.cnt == img->multi.cap) { | |
| 257 | 263 | img->multi.cap *= 2; | |