jypark pushed a commit to branch master.

commit e7990ed69330a2c8a566f633a9fac677526d8aab
Author: Jiyoun Park <[email protected]>
Date:   Sun May 5 00:01:57 2013 +0900

    * Evas: Fix gif loader can't load image which has normal frames and
    error frames
---
 ChangeLog                                          |  4 ++++
 NEWS                                               |  1 +
 src/modules/evas/loaders/gif/evas_image_load_gif.c | 17 +++++++++++++++--
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index df5c5e5..f20d613 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-05-30  Jiyoun Park (jypark)
+
+        * Evas: Fix gif loader can't load image which has normal frames and 
error frames
+
 2013-04-03  Rafael Antognolli
 
         * Evas: Added evas_event_input_mouse_move() for internal use only.
diff --git a/NEWS b/NEWS
index db11d25..8306436 100644
--- a/NEWS
+++ b/NEWS
@@ -257,3 +257,4 @@ Fixes:
     * Ecore-X: Fix selection parser to not overrun buffer read by using longs 
on 64bit.
     * Evas: Fix recursive proxy image rendering to just render black
     * Evas textblock: Fixed line size calculation when using multiple fonts.
+    * Evas: Fix gif loader can't load image which has normal frames and error 
frames
diff --git a/src/modules/evas/loaders/gif/evas_image_load_gif.c 
b/src/modules/evas/loaders/gif/evas_image_load_gif.c
index 8645c80..30eb974 100644
--- a/src/modules/evas/loaders/gif/evas_image_load_gif.c
+++ b/src/modules/evas/loaders/gif/evas_image_load_gif.c
@@ -8,6 +8,10 @@
 
 #include <gif_lib.h>
 
+#ifndef MIN
+# define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
 typedef struct _Gif_Frame Gif_Frame;
 
 typedef enum _Frame_Load_Type
@@ -699,6 +703,10 @@ evas_image_load_file_head_gif(Image_Entry *ie, const char 
*file, const char *key
    int            alpha;
    int            loop_count = -1;
    Eina_Bool      r = EINA_FALSE;
+   Eina_Bool      animated = EINA_FALSE;
+   //it is possible which gif file have error midle of frames,
+   //in that case we should play gif file until meet error frame.
+   int            image_count = 0;
 
    w = 0;
    h = 0;
@@ -753,6 +761,7 @@ evas_image_load_file_head_gif(Image_Entry *ie, const char 
*file, const char *key
      {
         if (DGifGetRecordType(gif, &rec) == GIF_ERROR)
           {
+             if (image_count > 1) break; //we should show normal frames.
              /* PrintGifError(); */
              *error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
              goto on_error;
@@ -782,6 +791,7 @@ evas_image_load_file_head_gif(Image_Entry *ie, const char 
*file, const char *key
                   img = NULL;
                   DGifGetCodeNext(gif, &img);
                }
+             image_count++;
           }
         else if (rec == EXTENSION_RECORD_TYPE)
           {
@@ -820,12 +830,15 @@ evas_image_load_file_head_gif(Image_Entry *ie, const char 
*file, const char *key
 
    if (alpha >= 0) ie->flags.alpha = 1;
 
-   if (gif->ImageCount > 1)
+   if ((gif->ImageCount > 1) || (image_count > 1))
+     animated = EINA_TRUE;
+
+   if (animated)
      {
         ie->flags.animated = 1;
         ie->loop_count = loop_count;
         ie->loop_hint = EVAS_IMAGE_ANIMATED_HINT_LOOP;
-        ie->frame_count = gif->ImageCount;
+        ie->frame_count = MIN(gif->ImageCount, image_count);
         ie->frames = NULL;
      }
 

-- 

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2

Reply via email to