summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaeun Choi <jaeun12.choi@samsung.com>2017-02-10 16:56:50 +0900
committerJaeun Choi <jaeun12.choi@samsung.com>2017-02-13 14:28:43 +0900
commit95d83e80406ddf48305cdbc91eecd340ecc4c6e1 (patch)
treee787991a4182003d05c282e47bf5805d75be1938
parent243e8a678b0bfc7aa819210aad1ba40b32803d1c (diff)
evas: fix bugs in gif image loader
gif's logical screen size (which is considered the image size) might be different from the size of each frame. when decoding a frame, the width and height of the decoded data should be based on the size of the frame, not on the size of the logical screen size. if a frame is decoded into a buffer of screen size, this might happen (frame = 6 X 3, logical screen = 5 X 3) OOOXXX OOOXX OOOXXX => XOOOX OOOXXX XXOOO @fix
Diffstat (limited to '')
-rw-r--r--src/modules/evas/image_loaders/gif/evas_image_load_gif.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/modules/evas/image_loaders/gif/evas_image_load_gif.c b/src/modules/evas/image_loaders/gif/evas_image_load_gif.c
index f20b8ccaad..56464494af 100644
--- a/src/modules/evas/image_loaders/gif/evas_image_load_gif.c
+++ b/src/modules/evas/image_loaders/gif/evas_image_load_gif.c
@@ -209,7 +209,8 @@ _new_frame(Evas_Image_Animated *animated,
209// data pointer 209// data pointer
210static Eina_Bool 210static Eina_Bool
211_decode_image(GifFileType *gif, DATA32 *data, int rowpix, int xin, int yin, 211_decode_image(GifFileType *gif, DATA32 *data, int rowpix, int xin, int yin,
212 int transparent, int x, int y, int w, int h, Eina_Bool fill) 212 int transparent, int fw, int fh,
213 int x, int y, int w, int h, Eina_Bool fill)
213{ 214{
214 int intoffset[] = { 0, 4, 2, 1 }; 215 int intoffset[] = { 0, 4, 2, 1 };
215 int intjump[] = { 8, 8, 4, 2 }; 216 int intjump[] = { 8, 8, 4, 2 };
@@ -224,14 +225,14 @@ _decode_image(GifFileType *gif, DATA32 *data, int rowpix, int xin, int yin,
224 225
225 // build a blob of memory to have pointers to rows of pixels 226 // build a blob of memory to have pointers to rows of pixels
226 // AND store the decoded gif pixels (1 byte per pixel) as welll 227 // AND store the decoded gif pixels (1 byte per pixel) as welll
227 rows = malloc((h * sizeof(GifRowType)) + (w * h * sizeof(GifPixelType))); 228 rows = malloc((fh * sizeof(GifRowType)) + (fw * fh * sizeof(GifPixelType)));
228 if (!rows) goto on_error; 229 if (!rows) goto on_error;
229 230
230 // fill in the pointers at the start 231 // fill in the pointers at the start
231 for (yy = 0; yy < h; yy++) 232 for (yy = 0; yy < fh; yy++)
232 { 233 {
233 rows[yy] = ((unsigned char *)rows) + (h * sizeof(GifRowType)) + 234 rows[yy] = ((unsigned char *)rows) + (fh * sizeof(GifRowType)) +
234 (yy * w * sizeof(GifPixelType)); 235 (yy * fw * sizeof(GifPixelType));
235 } 236 }
236 237
237 // if give is interlaced, walk interlace pattern and decode into rows 238 // if give is interlaced, walk interlace pattern and decode into rows
@@ -239,9 +240,9 @@ _decode_image(GifFileType *gif, DATA32 *data, int rowpix, int xin, int yin,
239 { 240 {
240 for (i = 0; i < 4; i++) 241 for (i = 0; i < 4; i++)
241 { 242 {
242 for (yy = intoffset[i]; yy < h; yy += intjump[i]) 243 for (yy = intoffset[i]; yy < fh; yy += intjump[i])
243 { 244 {
244 if (DGifGetLine(gif, rows[yy], w) != GIF_OK) 245 if (DGifGetLine(gif, rows[yy], fw) != GIF_OK)
245 goto on_error; 246 goto on_error;
246 } 247 }
247 } 248 }
@@ -249,9 +250,9 @@ _decode_image(GifFileType *gif, DATA32 *data, int rowpix, int xin, int yin,
249 // normal top to bottom - decode into rows 250 // normal top to bottom - decode into rows
250 else 251 else
251 { 252 {
252 for (yy = 0; yy < h; yy++) 253 for (yy = 0; yy < fh; yy++)
253 { 254 {
254 if (DGifGetLine(gif, rows[yy], w) != GIF_OK) 255 if (DGifGetLine(gif, rows[yy], fw) != GIF_OK)
255 goto on_error; 256 goto on_error;
256 } 257 }
257 } 258 }
@@ -745,6 +746,7 @@ open_file:
745 &x, &y, &w, &h); 746 &x, &y, &w, &h);
746 if (!_decode_image(gif, thisframe->data, prop->w, 747 if (!_decode_image(gif, thisframe->data, prop->w,
747 xin, yin, finfo->transparent, 748 xin, yin, finfo->transparent,
749 finfo->w, finfo->h,
748 x, y, w, h, first)) 750 x, y, w, h, first))
749 LOADERR(EVAS_LOAD_ERROR_CORRUPT_FILE); 751 LOADERR(EVAS_LOAD_ERROR_CORRUPT_FILE);
750 // mark as loaded and done 752 // mark as loaded and done
@@ -772,6 +774,7 @@ open_file:
772 // and decode the gif with overwriting 774 // and decode the gif with overwriting
773 if (!_decode_image(gif, pixels, prop->w, 775 if (!_decode_image(gif, pixels, prop->w,
774 xin, yin, finfo->transparent, 776 xin, yin, finfo->transparent,
777 finfo->w, finfo->h,
775 x, y, w, h, EINA_TRUE)) 778 x, y, w, h, EINA_TRUE))
776 LOADERR(EVAS_LOAD_ERROR_CORRUPT_FILE); 779 LOADERR(EVAS_LOAD_ERROR_CORRUPT_FILE);
777 // mark as loaded and done 780 // mark as loaded and done