login

<     >

2018-01-14 14:49:20 (UTC-02:00)

Marcel Rodrigues <marcelgmr@gmail.com>

Fix gif->frame index in render_frame_rect().

Even though gif->frame only stores pixels for the current frame,
it has the same size as the full canvas of the GIF file.

diff --git a/gifdec.c b/gifdec.c
index 9cd5ff2..112e0c4 100644
--- a/gifdec.c
+++ b/gifdec.c
@@ -391,7 +391,7 @@ render_frame_rect(gd_GIF *gif, uint8_t *buffer)
     i = gif->fy * gif->width + gif->fx;
     for (j = 0; j < gif->fh; j++) {
         for (k = 0; k < gif->fw; k++) {
-            index = gif->frame[j * gif->fw + k];
+            index = gif->frame[(gif->fy + j) * gif->width + gif->fx + k];
             color = &gif->palette->colors[index*3];
             if (!gif->gce.transparency || index != gif->gce.tindex)
                 memcpy(&buffer[(i+k)*3], color, 3);