diff --git a/src/giffunc.c b/src/giffunc.c index 2b88d73..c09a913 100644 --- a/src/giffunc.c +++ b/src/giffunc.c @@ -466,8 +466,10 @@ Gif_CopyImage(Gif_Image *src) void Gif_MakeImageEmpty(Gif_Image* gfi) { Gif_ReleaseUncompressedImage(gfi); Gif_ReleaseCompressedImage(gfi); - gfi->left = gfi->top = 0; - gfi->width = gfi->height = 1; + gfi->left = gfi->left < 0xFFFE ? gfi->left : 0xFFFE; + gfi->top = gfi->top < 0xFFFE ? gfi->top : 0xFFFE; + gfi->width = 1; + gfi->height = 1; gfi->transparent = 0; Gif_CreateUncompressedImage(gfi, 0); gfi->img[0][0] = 0; diff --git a/src/support.c b/src/support.c index 0abd08f..23ed316 100644 --- a/src/support.c +++ b/src/support.c @@ -1421,9 +1421,9 @@ analyze_crop(int nmerger, Gt_Crop* crop, int compress_immediately) } } - if (t > b) + if (t > b) { crop->w = crop->h = 0; - else { + } else { crop->x = l; crop->y = t; crop->w = r - l; diff --git a/src/xform.c b/src/xform.c index 8fdcf88..095e5cf 100644 --- a/src/xform.c +++ b/src/xform.c @@ -262,18 +262,18 @@ crop_image(Gif_Image* gfi, Gt_Frame* fr, int preserve_total_crop) gfi->img[j] = old_img[c.y + j] + c.x; gfi->img[c.h] = 0; Gif_DeleteArray(old_img); + gfi->left += c.x - fr->left_offset; + gfi->top += c.y - fr->top_offset; gfi->width = c.w; gfi->height = c.h; - } else if (preserve_total_crop) + } else if (preserve_total_crop) { Gif_MakeImageEmpty(gfi); - else { + } else { Gif_DeleteArray(gfi->img); gfi->img = 0; gfi->width = gfi->height = 0; } - gfi->left += c.x - fr->left_offset; - gfi->top += c.y - fr->top_offset; return gfi->img != 0; }