From 8b917ca253c34a7f7170720accac4130a835427c Mon Sep 17 00:00:00 2001 From: Jiyong Min Date: Mon, 21 Aug 2017 12:38:22 +0900 Subject: [PATCH] Refactoring __gif_get_index_in_colormap() function Change-Id: Ie5e664f4829f8c6e609422223ad52c0487dc4607 Signed-off-by: Jiyong Min --- gif/mm_util_gif.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/gif/mm_util_gif.c b/gif/mm_util_gif.c index 7a136f2..5406039 100755 --- a/gif/mm_util_gif.c +++ b/gif/mm_util_gif.c @@ -612,18 +612,20 @@ SUCCESS: return ret; } -int __gif_get_index_in_colormap(ColorMapObject * color_map, GifColorType get_color, int *index) +int __gif_get_index_in_colormap(gif_image_s *gif_image) { int i = 0; - mm_util_retvm_if(color_map == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter"); + mm_util_retvm_if(gif_image->image_desc.ColorMap == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter"); + mm_util_retvm_if(gif_image->image_desc.ColorMap->Colors == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter"); - *index = -1; + /* default is no transparent color */ + gif_image->graphic_control_block.TransparentColor = -1; - for (i = 0; i < color_map->ColorCount; i++) { - if(color_map->Colors[i].Red == get_color.Red && - color_map->Colors[i].Green == get_color.Green && - color_map->Colors[i].Blue == get_color.Blue) { - *index = i; + for (i = 0; i < gif_image->image_desc.ColorMap->ColorCount; i++) { + if(gif_image->image_desc.ColorMap->Colors[i].Red == gif_image->transparent_color.Red && + gif_image->image_desc.ColorMap->Colors[i].Green == gif_image->transparent_color.Green && + gif_image->image_desc.ColorMap->Colors[i].Blue == gif_image->transparent_color.Blue) { + gif_image->graphic_control_block.TransparentColor = i; break; } } @@ -1298,8 +1300,7 @@ int mm_util_gif_encode_add_image(mm_gif_file_h gif_file_h, mm_gif_image_h gif_im } if (gif_image->has_transparent) { - ret = __gif_get_index_in_colormap(gif_image->image_desc.ColorMap, - gif_image->transparent_color, &gif_image->graphic_control_block.TransparentColor); + ret = __gif_get_index_in_colormap(gif_image); mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "__gif_get_index_in_colormap failed"); } @@ -1308,7 +1309,7 @@ int mm_util_gif_encode_add_image(mm_gif_file_h gif_file_h, mm_gif_image_h gif_im mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "_gif_image_write_ext_blocks failed"); /* Write image description */ - ret = _gif_image_write_image_desc(gif_file, gif_image);\ + ret = _gif_image_write_image_desc(gif_file, gif_image); mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "_gif_image_write_image_desc failed"); /* Write image data */ -- 2.7.4