nsxiv4864f04
Regard gif disposal method; fix bug #18
+8 −6
2 files changed
| @@ -1,4 +1,4 @@ | |||
| 1 | − | VERSION = git-20110929 | |
| 1 | + | VERSION = git-20111011 | |
| 2 | 2 | ||
| 3 | 3 | CC = gcc | |
| 4 | 4 | CFLAGS = -Wall -pedantic -O2 | |
| @@ -137,6 +137,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) { | |||
| 137 | 137 | int intoffset[] = { 0, 4, 2, 1 }; | |
| 138 | 138 | int intjump[] = { 8, 8, 4, 2 }; | |
| 139 | 139 | int transp = -1; | |
| 140 | + | unsigned int disposal = 0, prev_disposal = 0; | |
| 140 | 141 | unsigned int delay = 0; | |
| 141 | 142 | bool err = false; | |
| 142 | 143 | ||
| @@ -178,8 +179,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) { | |||
| 178 | 179 | if (delay) | |
| 179 | 180 | delay = MAX(delay, MIN_GIF_DELAY); | |
| 180 | 181 | ||
| 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; | |
| 183 | 183 | } | |
| 184 | 184 | ext = NULL; | |
| 185 | 185 | DGifGetExtensionNext(gif, &ext); | |
| @@ -219,7 +219,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) { | |||
| 219 | 219 | if (i < y || i >= y + h || j < x || j >= x + w || | |
| 220 | 220 | rows[i-y][j-x] == transp) | |
| 221 | 221 | { | |
| 222 | − | if (prev_frame != NULL) | |
| 222 | + | if (prev_disposal != 2 && prev_frame != NULL) | |
| 223 | 223 | *ptr = prev_frame[i * sw + j]; | |
| 224 | 224 | else | |
| 225 | 225 | *ptr = bgpixel; | |
| @@ -246,12 +246,14 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) { | |||
| 246 | 246 | } | |
| 247 | 247 | ||
| 248 | 248 | imlib_context_set_image(im); | |
| 249 | − | prev_frame = imlib_image_get_data_for_reading_only(); | |
| 250 | − | ||
| 251 | 249 | imlib_image_set_format("gif"); | |
| 252 | 250 | if (transp >= 0) | |
| 253 | 251 | imlib_image_set_has_alpha(1); | |
| 254 | 252 | ||
| 253 | + | if (disposal != 3) | |
| 254 | + | prev_frame = imlib_image_get_data_for_reading_only(); | |
| 255 | + | prev_disposal = disposal; | |
| 256 | + | ||
| 255 | 257 | if (img->multi.cnt == img->multi.cap) { | |
| 256 | 258 | img->multi.cap *= 2; | |
| 257 | 259 | img->multi.frames = (img_frame_t*) | |