From: hj kim Date: Wed, 17 Jun 2020 02:04:41 +0000 (+0900) Subject: Fix wrong return value and improve image_util_extract_color_from_memory() X-Git-Tag: accepted/tizen/unified/20200626.133543~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F12%2F236412%2F2;p=platform%2Fcore%2Fapi%2Fimage-util.git Fix wrong return value and improve image_util_extract_color_from_memory() Change-Id: I4c12373dd3824c13c153abfa701726a2d1694dbe --- diff --git a/src/image_util.c b/src/image_util.c index 79d8a7b..cb18486 100644 --- a/src/image_util.c +++ b/src/image_util.c @@ -547,37 +547,32 @@ int image_util_calculate_buffer_size(int width, int height, image_util_colorspac int image_util_extract_color_from_memory(const unsigned char *image_buffer, int width, int height, unsigned char *rgb_r, unsigned char *rgb_g, unsigned char *rgb_b) { int ret = IMAGE_UTIL_ERROR_NONE; - - image_util_retvm_if((image_buffer == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "image_buffer is null"); - GModule *module = NULL; ModuleFunc mmutil_imgcv_module_func = NULL; + + image_util_retvm_if(image_buffer, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image_buffer"); + image_util_retvm_if(rgb_r, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid rgb_r"); + image_util_retvm_if(rgb_g, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid rgb_g"); + image_util_retvm_if(rgb_b, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid rgb_b"); + module = g_module_open(PATH_MMUTIL_IMGCV_LIB, G_MODULE_BIND_LAZY); - image_util_retvm_if((module == NULL), IMAGE_UTIL_ERROR_NO_SUCH_FILE, "fail to open module"); + image_util_retvm_if(!module, IMAGE_UTIL_ERROR_INVALID_OPERATION, "fail to open module"); if (!g_module_symbol(module, IMGCV_FUNC_NAME, (gpointer *)&mmutil_imgcv_module_func)) { image_util_error("fail to g_module_symbol"); g_module_close(module); - return IMAGE_UTIL_ERROR_INVALID_OPERATION; } - if (!mmutil_imgcv_module_func) + if (!mmutil_imgcv_module_func) { + image_util_error("fail to get mmutil_imgcv_module_func"); g_module_close(module); + return IMAGE_UTIL_ERROR_INVALID_OPERATION; + } - image_util_retvm_if((mmutil_imgcv_module_func == NULL), IMAGE_UTIL_ERROR_INVALID_OPERATION, "fail to get symbol"); - - unsigned char r_color, g_color, b_color; - ret = mmutil_imgcv_module_func((void *)image_buffer, width, height, &r_color, &g_color, &b_color); - - *rgb_r = r_color; - *rgb_g = g_color; - *rgb_b = b_color; + ret = mmutil_imgcv_module_func((void *)image_buffer, width, height, rgb_r, rgb_g, rgb_b); - if (module) { - g_module_close(module); - module = NULL; - } + g_module_close(module); return _image_error_capi(ret); }