From e7990ed69330a2c8a566f633a9fac677526d8aab Mon Sep 17 00:00:00 2001 From: Jiyoun Park Date: Sun, 5 May 2013 00:01:57 +0900 Subject: [PATCH] * Evas: Fix gif loader can't load image which has normal frames and error frames --- ChangeLog | 4 ++++ NEWS | 1 + .../evas/loaders/gif/evas_image_load_gif.c | 17 +++++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index df5c5e5630..f20d61345f 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 db11d25221..8306436cf5 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 8645c80881..30eb9749fa 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 +#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; }