From 9b0af8d4b269a0468c028e2eae691aabde6c907b Mon Sep 17 00:00:00 2001
From: Manuel Gunther <siebenkopf@googlemail.com>
Date: Thu, 2 Mar 2017 11:09:54 -0700
Subject: [PATCH] Switched back to reading first image; later images might be
 incomplete

---
 bob/io/image/cpp/gif.cpp | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/bob/io/image/cpp/gif.cpp b/bob/io/image/cpp/gif.cpp
index c99df81..e6cb0b4 100644
--- a/bob/io/image/cpp/gif.cpp
+++ b/bob/io/image/cpp/gif.cpp
@@ -441,13 +441,23 @@ static void im_load_color(boost::shared_ptr<GifFileType> in_file, bob::io::base:
           // Need to perform 4 passes on the images:
           for(int i=0; i<4; ++i)
             for(int j=row+InterlacedOffset[i]; j<row+height; j+=InterlacedJumps[i]) {
-              error = DGifGetLine(in_file.get(), &screen_buffer[j][col], width);
+              if (image_found)
+                // image buffer already filled; read in into junk buffer
+                error = DGifGetLine(in_file.get(), &temp_buffer[col], width);
+              else
+                // read into image buffer
+                error = DGifGetLine(in_file.get(), &screen_buffer[j][col], width);
               if(error == GIF_ERROR) GifErrorHandler("DGifGetLine", in_file->Error);
             }
         }
         else {
           for(int i=0; i<height; ++i) {
-            error = DGifGetLine(in_file.get(), &screen_buffer[row++][col], width);
+            if (image_found)
+              // image buffer already filled; read in into junk buffer
+              error = DGifGetLine(in_file.get(), &temp_buffer[col], width);
+            else
+              // read into image buffer
+              error = DGifGetLine(in_file.get(), &screen_buffer[row++][col], width);
             if(error == GIF_ERROR) GifErrorHandler("DGifGetLine", in_file->Error);
           }
         }
-- 
GitLab