aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBert Münnich <ber.t@gmx.com>2011-10-17 18:39:33 +0200
committerBert Münnich <ber.t@gmx.com>2011-10-17 18:39:33 +0200
commit3e2523818b2420a86d71ac7c908ddcbb800abd38 (patch)
tree646019d08559654d3887809cc0ac3bed1c4f48b3
parent55da6fb8dd58829555172b57a0237d6c3381e573 (diff)
Fixed handling of gif disposal method (issue #23)
-rw-r--r--Makefile2
-rw-r--r--image.c10
2 files changed, 9 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 4191c85..25a40fc 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION = git-20111016
+VERSION = git-20111017
CC = gcc
CFLAGS = -ansi -Wall -pedantic -O2
diff --git a/image.c b/image.c
index 8df02ec..2fe228f 100644
--- a/image.c
+++ b/image.c
@@ -133,6 +133,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) {
Imlib_Image *im;
int i, j, bg, r, g, b;
int x, y, w, h, sw, sh;
+ int px, py, pw, ph;
int intoffset[] = { 0, 4, 2, 1 };
int intjump[] = { 8, 8, 4, 2 };
int transp = -1;
@@ -156,6 +157,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) {
bg = gif->SBackGroundColor;
sw = gif->SWidth;
sh = gif->SHeight;
+ px = py = pw = ph = 0;
do {
if (DGifGetRecordType(gif, &rec) == GIF_ERROR) {
@@ -218,10 +220,13 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) {
if (i < y || i >= y + h || j < x || j >= x + w ||
rows[i-y][j-x] == transp)
{
- if (prev_disposal != 2 && prev_frame != NULL)
+ if (prev_frame != NULL && (prev_disposal != 2 ||
+ i < py || i >= py + ph || j < px || j >= px + pw))
+ {
*ptr = prev_frame[i * sw + j];
- else
+ } else {
*ptr = bgpixel;
+ }
} else {
r = cmap->Colors[rows[i-y][j-x]].Red;
g = cmap->Colors[rows[i-y][j-x]].Green;
@@ -252,6 +257,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) {
if (disposal != 3)
prev_frame = imlib_image_get_data_for_reading_only();
prev_disposal = disposal;
+ px = x, py = y, pw = w, ph = h;
if (img->multi.cnt == img->multi.cap) {
img->multi.cap *= 2;