Replace and add functions to use unified parameter 72/200772/21 accepted/tizen/unified/20190311.220536 submit/tizen/20190311.013617
authorjiyong.min <jiyong.min@samsung.com>
Mon, 4 Mar 2019 06:37:50 +0000 (15:37 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Fri, 8 Mar 2019 05:01:33 +0000 (14:01 +0900)
[Repleaced function]
 - mm_util_create_handle() to mm_image_create_image()
 - mm_util_get_image() to mm_image_get_image()
 - mm_util_destroy_handle() to mm_image_destroy_image()

[Added function]
 - mm_image_debug_image()
 - mm_image_set_delay_time()
 - mm_image_get_delay_time()

< This change will be related with image-util, dcm-service,
libmedia-thumbnail and thumbnail-util packages.
The packages must use new functions. >

Change-Id: Ifec56a4fbb73bac9438389ad2fb8a27bb2dc827e

common/include/mm_util_image.h [new file with mode: 0644]
common/include/mm_util_private.h
common/include/mm_util_type.h
common/mm_util_image.c [new file with mode: 0644]
jpeg/mm_util_jpeg.c
magick/CMakeLists.txt
magick/include/mm_util_magick.h
magick/mm_util_magick.c [changed mode: 0755->0644]
magick/test/mm_util_magick_testsuite.c [changed mode: 0755->0644]

diff --git a/common/include/mm_util_image.h b/common/include/mm_util_image.h
new file mode 100644 (file)
index 0000000..9c683f6
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __MM_UTIL_IMAGE_H__
+#define __MM_UTIL_IMAGE_H__
+
+#include <glib.h>
+#include "mm_util_type.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+gboolean mm_image_is_valid_image(mm_util_image_h image);
+void mm_image_debug_image(mm_util_image_h image, const char *message);
+
+int mm_image_create_image(unsigned int width, unsigned int height,
+               mm_util_color_format_e color, unsigned char *data, size_t size,
+               mm_util_image_h *image);
+
+int mm_image_set_delay_time(mm_util_image_h image, unsigned int delay_time);
+int mm_image_get_delay_time(mm_util_image_h image, unsigned int *delay_time);
+/* After @data is used, it must be released using free().*/
+int mm_image_get_image(mm_util_image_h image, unsigned int *width,
+               unsigned int *height, mm_util_color_format_e *color,
+               unsigned char **data, size_t *size);
+
+void mm_image_destroy_image(mm_util_image_h image);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif   /*__MM_UTIL_IMAGE_H__*/
index 601d42d..081ba42 100755 (executable)
@@ -25,8 +25,9 @@
 #include <glib.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include "mm_util_debug.h"
 #include "mm_util_type.h"
+#include "mm_util_debug.h"
+#include "mm_util_image.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -49,6 +50,7 @@ extern "C" {
 #define MM_UTIL_ROUND_DOWN_16(num) ((num)&(~15))
 
 #define IS_VALID_COLOR(color)  mm_util_is_valid_color_format(color)
+#define IS_VALID_IMAGE(image)  mm_image_is_valid_image(image)
 
 gboolean mm_util_is_valid_color_format(mm_util_color_format_e color);
 
index e7b0cad..00b8541 100755 (executable)
@@ -26,6 +26,8 @@
 extern "C" {
 #endif
 
+typedef void *mm_util_image_h;
+
 /**
  * error type
  */
diff --git a/common/mm_util_image.c b/common/mm_util_image.c
new file mode 100644 (file)
index 0000000..e66253a
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+* Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <stdio.h>
+
+#include "mm_util_private.h"
+
+gboolean mm_image_is_valid_image(mm_util_image_h image)
+{
+       mm_image_info_s *_image = (mm_image_info_s *)image;
+
+       mm_util_retvm_if(image == NULL, FALSE, "Invalid image");
+       mm_util_retvm_if(_image->width == 0, FALSE, "Invalid width");
+       mm_util_retvm_if(_image->height == 0, FALSE, "Invalid height");
+       mm_util_retvm_if(!IS_VALID_COLOR(_image->color), FALSE, "Invalid color [%d]", _image->color);
+       mm_util_retvm_if((_image->data == NULL) || (_image->size == 0), FALSE, "Invalid data [%zu, %p]", _image->size, _image->data);
+
+       return TRUE;
+}
+
+void mm_image_debug_image(mm_util_image_h image, const char *message)
+{
+       mm_image_info_s *_image = (mm_image_info_s *)image;
+
+       mm_util_retm_if(image == NULL, "Invalid image");
+
+       if (message)
+               mm_util_sec_debug("[%s] w [%u], h [%u], color [%u], data [%p], size [%zu]", message,
+                       _image->width, _image->height, _image->color, _image->data, _image->size);
+       else
+               mm_util_sec_debug("w [%u], h [%u], color [%u], data [%p], size [%zu]",
+                       _image->width, _image->height, _image->color, _image->data, _image->size);
+}
+
+int mm_image_create_image(unsigned int width, unsigned int height,
+               mm_util_color_format_e color, unsigned char *data, size_t size,
+               mm_util_image_h *image)
+{
+       mm_image_info_s *_image = NULL;
+
+       /* initialize return value */
+       *image = NULL;
+
+       mm_util_retvm_if(image == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid image");
+       mm_util_retvm_if(width == 0, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid width");
+       mm_util_retvm_if(height == 0, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid height");
+       mm_util_retvm_if(!IS_VALID_COLOR(color), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid color [%d]", color);
+       mm_util_retvm_if(data == NULL || (size == 0), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid data");
+
+       _image = (mm_image_info_s *)calloc(1, sizeof(mm_image_info_s));
+       mm_util_retvm_if((_image == NULL), MM_UTIL_ERROR_OUT_OF_MEMORY, "Memory allocation failed");
+
+       _image->data = calloc(1, size);
+       if (_image->data == NULL) {
+               mm_util_error("Memory allocation failed");
+               mm_image_destroy_image(_image);
+               return MM_UTIL_ERROR_OUT_OF_MEMORY;
+       }
+
+       memcpy(_image->data, data, size);
+       _image->size = size;
+       _image->width = width;
+       _image->height = height;
+       _image->color = color;
+
+       mm_util_sec_debug("w [%u], h [%u], color [%u], data [%p], size [%zu]",
+               _image->width, _image->height, _image->color, _image->data, _image->size);
+
+       *image = (mm_util_image_h)_image;
+
+       return MM_UTIL_ERROR_NONE;
+}
+
+int mm_image_set_delay_time(mm_util_image_h image, unsigned int delay_time)
+{
+       mm_image_info_s *_image = (mm_image_info_s *)image;
+
+       mm_util_retvm_if(image == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid image");
+
+       _image->delay_time = delay_time;
+
+       return MM_UTIL_ERROR_NONE;
+}
+
+int mm_image_get_delay_time(mm_util_image_h image, unsigned int *delay_time)
+{
+       mm_image_info_s *_image = (mm_image_info_s *)image;
+
+       mm_util_retvm_if(image == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid image");
+       mm_util_retvm_if(delay_time == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid delay_time");
+
+       *delay_time = _image->delay_time;
+
+       return MM_UTIL_ERROR_NONE;
+}
+
+int mm_image_get_image(mm_util_image_h image, unsigned int *width,
+               unsigned int *height, mm_util_color_format_e *color,
+               unsigned char **data, size_t *size)
+{
+       mm_image_info_s *_image = (mm_image_info_s *)image;
+       unsigned char *_data = NULL;
+
+       mm_util_retvm_if(!IS_VALID_IMAGE(image), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid image");
+
+       if (width)
+               *width = _image->width;
+
+       if (height)
+               *height = _image->height;
+
+       if (color)
+               *color = _image->color;
+
+       if (data && size) {
+               _data = calloc(1, _image->size);
+               mm_util_retvm_if(_data == NULL, MM_UTIL_ERROR_OUT_OF_MEMORY, "Memory allocation failed");
+               memcpy(_data, _image->data, _image->size);
+               *data = _data;
+               *size = _image->size;
+       }
+
+       return MM_UTIL_ERROR_NONE;
+}
+
+void mm_image_destroy_image(mm_util_image_h image)
+{
+       mm_image_info_s *_image = (mm_image_info_s *)image;
+
+       mm_util_retm_if(image == NULL, "Invalid image");
+
+       MMUTIL_SAFE_FREE(_image->data);
+       MMUTIL_SAFE_FREE(_image);
+}
index c08e1b5..8a8e639 100755 (executable)
@@ -109,7 +109,7 @@ static int __mm_image_encode_with_libjpeg(mm_util_jpeg_cont_format_e control_for
        data[1] = cb;
        data[2] = cr;
 
-       mm_util_debug("rawdata[%p] width[%d] height[%d] color_format[%u] quality[%d]", rawdata, width, height, color_format, quality);
+       mm_util_debug("rawdata[%p] width[%u] height[%u] color_format[%u] quality[%d]", rawdata, width, height, color_format, quality);
 
        cinfo.err = jpeg_std_error(&jerr); /*  Errors get written to stderr */
 
index 1d2177b..4552d95 100644 (file)
@@ -38,7 +38,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
 
 aux_source_directory(. SOURCES)
 ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
-TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS} mmutil_common)
 SET_TARGET_PROPERTIES(${fw_name}
        PROPERTIES
        VERSION ${VERSION}
index 8c1216e..4c54789 100755 (executable)
@@ -27,8 +27,7 @@ extern "C" {
 #endif
 
 #include "mm_util_type.h"
-
-typedef void *mm_util_image_h;
+#include "mm_util_image.h"
 
 /**
  * Image rotation types
@@ -52,12 +51,6 @@ typedef enum {
        IMG_CODEC_UNKNOWN_TYPE,
 } mm_util_img_codec_type;
 
-int mm_util_create_handle(mm_util_image_h *handle, const unsigned char *buffer, unsigned int width, unsigned int height, size_t size, mm_util_color_format_e format);
-
-/*You must release buffer using free().*/
-int mm_util_get_image(mm_util_image_h handle, unsigned char **buffer, unsigned int *width, unsigned int *height, size_t *size, mm_util_color_format_e *format);
-int mm_util_destroy_handle(mm_util_image_h handle);
-
 int mm_util_rotate_B_B(mm_util_image_h src_handle, mm_util_magick_rotate_type angle, mm_util_image_h *dst_handle);
 int mm_util_rotate_B_P(mm_util_image_h src_handle, mm_util_magick_rotate_type angle, const char *dst_path);
 int mm_util_rotate_P_B(const char *src_path, mm_util_magick_rotate_type angle, mm_util_color_format_e req_format, mm_util_image_h *dst_handle);
old mode 100755 (executable)
new mode 100644 (file)
index 0971b5a..7f5df56
@@ -351,59 +351,6 @@ static bool __mm_util_check_angle(mm_util_magick_rotate_type angle)
                return FALSE;
 }
 
-int mm_util_create_handle(mm_util_image_h *handle, const unsigned char *buffer, unsigned int width, unsigned int height, size_t size, mm_util_color_format_e format)
-{
-       int ret = MM_UTIL_ERROR_NONE;
-
-       mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
-
-       mm_image_info_s *_handle = (mm_image_info_s*)calloc(1, sizeof(mm_image_info_s));
-       mm_util_retvm_if(_handle == NULL, MM_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
-       _handle->data = (unsigned char *)buffer;
-       _handle->width = width;
-       _handle->height = height;
-       _handle->size = size;
-       _handle->color = format;
-
-       *handle = (mm_util_image_h)_handle;
-
-       return ret;
-}
-
-int mm_util_get_image(mm_util_image_h handle, unsigned char **buffer, unsigned int *width, unsigned int *height, size_t *size, mm_util_color_format_e *format)
-{
-       int ret = MM_UTIL_ERROR_NONE;
-
-       mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
-       mm_util_retvm_if(buffer == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid buffer");
-       mm_util_retvm_if(width == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid width");
-       mm_util_retvm_if(height == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid height");
-       mm_util_retvm_if(size == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid size");
-       mm_util_retvm_if(format == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid format");
-
-       mm_image_info_s *_handle = (mm_image_info_s*)handle;
-
-       *buffer = _handle->data;
-       *width = _handle->width;
-       *height = _handle->height;
-       *size = _handle->size;
-       *format = _handle->color;
-
-       return ret;
-}
-
-int mm_util_destroy_handle(mm_util_image_h handle)
-{
-       mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
-
-       mm_image_info_s *_handle = (mm_image_info_s*)handle;
-
-       MMUTIL_SAFE_FREE(_handle);
-
-       return MM_UTIL_ERROR_NONE;
-}
-
 int mm_util_rotate_B_B(mm_util_image_h src_handle, mm_util_magick_rotate_type angle, mm_util_image_h *dst_handle)
 {
        int ret = MM_UTIL_ERROR_NONE;
@@ -447,11 +394,11 @@ int mm_util_rotate_B_B(mm_util_image_h src_handle, mm_util_magick_rotate_type an
                goto ERROR;
        }
 
-       ret = mm_util_create_handle(dst_handle, pixels, _processed_image->columns, _processed_image->rows, pixels_size, _src_handle->color);
-       if (ret != MM_UTIL_ERROR_NONE) {
-               mm_util_error("Error: __mm_util_write_image_to_buffer failed.");
-               MagickFree(pixels);
-       }
+       ret = mm_image_create_image(_processed_image->columns, _processed_image->rows, _src_handle->color, pixels, pixels_size, dst_handle);
+       if (ret != MM_UTIL_ERROR_NONE)
+               mm_util_error("Error: mm_image_create_image failed.");
+
+       MagickFree(pixels);
 
 ERROR:
 
@@ -556,11 +503,11 @@ int mm_util_rotate_P_B(const char *src_path, mm_util_magick_rotate_type angle, m
                goto ERROR;
        }
 
-       ret = mm_util_create_handle(dst_handle, pixels, _processed_image->columns, _processed_image->rows, pixels_size, req_format);
-       if (ret != MM_UTIL_ERROR_NONE) {
-               mm_util_error("Error: __mm_util_write_image_to_buffer failed.");
-               MagickFree(pixels);
-       }
+       ret = mm_image_create_image(_processed_image->columns, _processed_image->rows, req_format, pixels, pixels_size, dst_handle);
+       if (ret != MM_UTIL_ERROR_NONE)
+               mm_util_error("Error: mm_image_create_image failed.");
+
+       MagickFree(pixels);
 
 ERROR:
 
@@ -664,11 +611,11 @@ int mm_util_resize_B_B(mm_util_image_h src_handle, unsigned int req_width, unsig
                goto ERROR;
        }
 
-       ret = mm_util_create_handle(dst_handle, pixels, _processed_image->columns, _processed_image->rows, pixels_size, _src_handle->color);
-       if (ret != MM_UTIL_ERROR_NONE) {
-               mm_util_error("Error: __mm_util_write_image_to_buffer failed.");
-               MagickFree(pixels);
-       }
+       ret = mm_image_create_image(_processed_image->columns, _processed_image->rows, _src_handle->color, pixels, pixels_size, dst_handle);
+       if (ret != MM_UTIL_ERROR_NONE)
+               mm_util_error("Error: mm_image_create_image failed.");
+
+       MagickFree(pixels);
 
 ERROR:
 
@@ -785,11 +732,11 @@ int mm_util_resize_P_B(const char *src_path, unsigned int req_width, unsigned in
                goto ERROR;
        }
 
-       ret = mm_util_create_handle(dst_handle, pixels, _processed_image->columns, _processed_image->rows, pixels_size, req_format);
-       if (ret != MM_UTIL_ERROR_NONE) {
-               mm_util_error("Error: __mm_util_write_image_to_buffer failed.");
-               MagickFree(pixels);
-       }
+       ret = mm_image_create_image(_processed_image->columns, _processed_image->rows, req_format, pixels, pixels_size, dst_handle);
+       if (ret != MM_UTIL_ERROR_NONE)
+               mm_util_error("Error: mm_image_create_image failed.");
+
+       MagickFree(pixels);
 
 ERROR:
 
@@ -891,11 +838,11 @@ int mm_util_convert_B_B(mm_util_image_h src_handle, mm_util_color_format_e req_f
                goto ERROR;
        }
 
-       ret = mm_util_create_handle(dst_handle, pixels, _image->columns, _image->rows, pixels_size, _src_handle->color);
-       if (ret != MM_UTIL_ERROR_NONE) {
-               mm_util_error("Error: __mm_util_write_image_to_buffer failed.");
-               MagickFree(pixels);
-       }
+       ret = mm_image_create_image(_image->columns, _image->rows, _src_handle->color, pixels, pixels_size, dst_handle);
+       if (ret != MM_UTIL_ERROR_NONE)
+               mm_util_error("Error: mm_image_create_image failed.");
+
+       MagickFree(pixels);
 
 ERROR:
 
old mode 100755 (executable)
new mode 100644 (file)
index dfd0aae..8d28563
@@ -109,13 +109,13 @@ static void __save_to_file(mm_util_image_h handle, const char *out_path)
        size_t size = 0;
        mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
 
-       ret = mm_util_get_image(handle, &buffer, &width, &height, &size, &format);
+       ret = mm_image_get_image(handle, &width, &height, &format, &buffer, &size);
        if (ret != MM_UTIL_ERROR_NONE) {
-               printf("Fail mm_util_get_image [%d]\n", ret);
+               printf("Fail mm_image_get_image [%d]\n", ret);
                return;
        }
 
-       printf("[save to file] buffer[%p], width[%d], height[%d], size[%zu], format [%d], out_path [%s]\n", buffer, width, height, size, format, out_path);
+       printf("[save to file] buffer[%p], width[%u], height[%u], size[%zu], format [%d], out_path [%s]\n", buffer, width, height, size, format, out_path);
 
        __write_to_file(out_path, buffer, size);
 
@@ -124,7 +124,8 @@ static void __save_to_file(mm_util_image_h handle, const char *out_path)
        return;
 }
 
-static int __get_buffer_for_test(mm_util_color_format_e req_format, unsigned char **buffer,  unsigned int *width, unsigned int *height, size_t *size, mm_util_color_format_e *format)
+static int __get_buffer_for_test(mm_util_color_format_e req_format, unsigned char **buffer,
+               unsigned int *width, unsigned int *height, size_t *size, mm_util_color_format_e *format)
 {
        int ret = MM_UTIL_ERROR_NONE;
        mm_util_image_h dst_handle = NULL;
@@ -136,24 +137,17 @@ static int __get_buffer_for_test(mm_util_color_format_e req_format, unsigned cha
                return ret;
        }
 
-       ret = mm_util_get_image(dst_handle, buffer, width, height, size, format);
+       ret = mm_image_get_image(dst_handle, width, height, format, buffer, size);
        if (ret != MM_UTIL_ERROR_NONE) {
-               printf("Fail mm_util_get_image [%d]\n", ret);
-               ret = mm_util_destroy_handle(dst_handle);
-               if (ret != MM_UTIL_ERROR_NONE)
-                       printf("Fail mm_util_destroy_handle [%d]\n", ret);
+               printf("Fail mm_image_get_image [%d]\n", ret);
+               mm_image_destroy_image(dst_handle);
                MM_UTIL_SAFE_FREE(*buffer);
                return ret;
        }
 
-       printf("[get_buffer] buffer[%p], width[%d], height[%d], size[%zu], format [%d]\n", *buffer, *width, *height, *size, *format);
+       printf("[get_buffer] buffer[%p], width[%u], height[%u], size[%zu], format [%d]\n", *buffer, *width, *height, *size, *format);
 
-       ret = mm_util_destroy_handle(dst_handle);
-       if (ret != MM_UTIL_ERROR_NONE) {
-               printf("Fail mm_util_destroy_handle [%d]\n", ret);
-               MM_UTIL_SAFE_FREE(*buffer);
-               return ret;
-       }
+       mm_image_destroy_image(dst_handle);
 
        return ret;
 }
@@ -178,10 +172,10 @@ static int _magick_resize_P_P_test(unsigned int req_width, unsigned int req_heig
        char * src_path = "/opt/usr/home/owner/origin.jpg";
        char dst_path[1024] = {0, };
        memset(dst_path, 0x00, sizeof(dst_path));
-       snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_pp_%d_%d.jpg", req_width, req_height);
+       snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_pp_%u_%u.jpg", req_width, req_height);
        //snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_%d_%d.png", req_width, req_height);
 
-       printf("* Resize P P Test * W * H = [%d * %d], path = [%s] \n", req_width, req_height, dst_path);
+       printf("* Resize P P Test * W * H = [%u * %u], path = [%s] \n", req_width, req_height, dst_path);
 
        ret = mm_util_resize_P_P(src_path, req_width, req_height, dst_path);
        if (ret != MM_UTIL_ERROR_NONE)
@@ -206,11 +200,7 @@ static int _magick_rotate_P_B_test(mm_util_magick_rotate_type angle, mm_util_col
 
        __save_to_file(dst_handle, __get_dst_raw_path(angle));
 
-       ret = mm_util_destroy_handle(dst_handle);
-       if (ret != MM_UTIL_ERROR_NONE) {
-               printf("Fail mm_util_destroy_handle [%d]\n", ret);
-               return ret;
-       }
+       mm_image_destroy_image(dst_handle);
 
        return ret;
 }
@@ -222,9 +212,9 @@ static int _magick_resize_P_B_test(unsigned int req_width, unsigned int req_heig
        char * src_path = "/opt/usr/home/owner/origin.jpg";
        char dst_path[1024] = {0, };
        memset(dst_path, 0x00, sizeof(dst_path));
-       snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_pb_%d_%d.raw", req_width, req_height);
+       snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_pb_%u_%u.raw", req_width, req_height);
 
-       printf("* Resize P B Test * W * H [%d * %d], foramt [%d], path [%s]\n", req_width, req_height, req_format, dst_path);
+       printf("* Resize P B Test * W * H [%u * %u], foramt [%d], path [%s]\n", req_width, req_height, req_format, dst_path);
 
        ret = mm_util_resize_P_B(src_path, req_width, req_height, req_format, &dst_handle);
        if (ret != MM_UTIL_ERROR_NONE) {
@@ -234,11 +224,7 @@ static int _magick_resize_P_B_test(unsigned int req_width, unsigned int req_heig
 
        __save_to_file(dst_handle, dst_path);
 
-       ret = mm_util_destroy_handle(dst_handle);
-       if (ret != MM_UTIL_ERROR_NONE) {
-               printf("Fail mm_util_destroy_handle [%d]\n", ret);
-               return ret;
-       }
+       mm_image_destroy_image(dst_handle);
 
        return ret;
 }
@@ -261,9 +247,9 @@ static int _magick_rotate_B_P_test(mm_util_magick_rotate_type angle, mm_util_col
                return ret;
        }
 
-       ret = mm_util_create_handle(&src_handle, buffer, width, height, size, format);
+       ret = mm_image_create_image(width, height, format, buffer, size, &src_handle);
        if (ret != MM_UTIL_ERROR_NONE) {
-               printf("Fail mm_util_create_handle [%d]\n", ret);
+               printf("Fail mm_image_create_image [%d]\n", ret);
                MM_UTIL_SAFE_FREE(buffer);
                return ret;
        }
@@ -272,9 +258,7 @@ static int _magick_rotate_B_P_test(mm_util_magick_rotate_type angle, mm_util_col
        if (ret != MM_UTIL_ERROR_NONE)
                printf("Fail mm_util_rotate_B_P [%d]\n", ret);
 
-       ret = mm_util_destroy_handle(src_handle);
-       if (ret != MM_UTIL_ERROR_NONE)
-               printf("Fail mm_util_destroy_handle [%d]\n", ret);
+       mm_image_destroy_image(src_handle);
 
        MM_UTIL_SAFE_FREE(buffer);
 
@@ -292,9 +276,9 @@ static int _magick_resize_B_P_test(unsigned int req_width, unsigned int req_heig
        mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
        char dst_path[1024] = {0, };
        memset(dst_path, 0x00, sizeof(dst_path));
-       snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_bp_%d_%d.jpg", req_width, req_height);
+       snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_bp_%u_%u.jpg", req_width, req_height);
 
-       printf("* Resize B P Test * W * H [%d * %d], foramt [%d], path [%s]\n", req_width, req_height, req_format, dst_path);
+       printf("* Resize B P Test * W * H [%u * %u], foramt [%d], path [%s]\n", req_width, req_height, req_format, dst_path);
 
        ret = __get_buffer_for_test(req_format, &buffer, &width, &height, &size, &format);
        if (ret != MM_UTIL_ERROR_NONE) {
@@ -302,9 +286,9 @@ static int _magick_resize_B_P_test(unsigned int req_width, unsigned int req_heig
                return ret;
        }
 
-       ret = mm_util_create_handle(&src_handle, buffer, width, height, size, format);
+       ret = mm_image_create_image(width, height, format, buffer, size, &src_handle);
        if (ret != MM_UTIL_ERROR_NONE) {
-               printf("Fail mm_util_create_handle [%d]\n", ret);
+               printf("Fail mm_image_create_image [%d]\n", ret);
                MM_UTIL_SAFE_FREE(buffer);
                return ret;
        }
@@ -313,9 +297,7 @@ static int _magick_resize_B_P_test(unsigned int req_width, unsigned int req_heig
        if (ret != MM_UTIL_ERROR_NONE)
                printf("Fail mm_util_resize_B_P [%d]\n", ret);
 
-       ret = mm_util_destroy_handle(src_handle);
-       if (ret != MM_UTIL_ERROR_NONE)
-               printf("Fail mm_util_destroy_handle [%d]\n", ret);
+       mm_image_destroy_image(src_handle);
 
        MM_UTIL_SAFE_FREE(buffer);
 
@@ -341,9 +323,9 @@ static int _magick_rotate_B_B_test(mm_util_magick_rotate_type angle, mm_util_col
                return ret;
        }
 
-       ret = mm_util_create_handle(&src_handle, buffer, width, height, size, format);
+       ret = mm_image_create_image(width, height, format, buffer, size, &src_handle);
        if (ret != MM_UTIL_ERROR_NONE) {
-               printf("Fail mm_util_create_handle [%d]\n", ret);
+               printf("Fail mm_image_create_image [%d]\n", ret);
                MM_UTIL_SAFE_FREE(buffer);
                return ret;
        }
@@ -356,13 +338,8 @@ static int _magick_rotate_B_B_test(mm_util_magick_rotate_type angle, mm_util_col
 
        __save_to_file(dst_handle, __get_dst_raw_path(angle));
 
-       ret = mm_util_destroy_handle(src_handle);
-       if (ret != MM_UTIL_ERROR_NONE)
-               printf("Fail destroy src_handle [%d]\n", ret);
-
-       ret = mm_util_destroy_handle(dst_handle);
-       if (ret != MM_UTIL_ERROR_NONE)
-               printf("Fail destroy dst_handle [%d]\n", ret);
+       mm_image_destroy_image(src_handle);
+       mm_image_destroy_image(dst_handle);
 
        return ret;
 }
@@ -379,9 +356,9 @@ static int _magick_resize_B_B_test(unsigned int req_width, unsigned int req_heig
        mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
        char dst_path[1024] = {0, };
        memset(dst_path, 0x00, sizeof(dst_path));
-       snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_bb_%d_%d.raw", req_width, req_height);
+       snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/resize_bb_%u_%u.raw", req_width, req_height);
 
-       printf("* Resize B B Test * W * H [%d * %d], foramt [%d], path [%s]\n", req_width, req_height, req_format, dst_path);
+       printf("* Resize B B Test * W * H [%u * %u], foramt [%d], path [%s]\n", req_width, req_height, req_format, dst_path);
 
        ret = __get_buffer_for_test(req_format, &buffer, &width, &height, &size, &format);
        if (ret != MM_UTIL_ERROR_NONE) {
@@ -389,9 +366,9 @@ static int _magick_resize_B_B_test(unsigned int req_width, unsigned int req_heig
                return ret;
        }
 
-       ret = mm_util_create_handle(&src_handle, buffer, width, height, size, format);
+       ret = mm_image_create_image(width, height, format, buffer, size, &src_handle);
        if (ret != MM_UTIL_ERROR_NONE) {
-               printf("Fail mm_util_create_handle [%d]\n", ret);
+               printf("Fail mm_image_create_image [%d]\n", ret);
                MM_UTIL_SAFE_FREE(buffer);
                return ret;
        }
@@ -404,13 +381,8 @@ static int _magick_resize_B_B_test(unsigned int req_width, unsigned int req_heig
 
        __save_to_file(dst_handle, dst_path);
 
-       ret = mm_util_destroy_handle(src_handle);
-       if (ret != MM_UTIL_ERROR_NONE)
-               printf("Fail destroy src_handle [%d]\n", ret);
-
-       ret = mm_util_destroy_handle(dst_handle);
-       if (ret != MM_UTIL_ERROR_NONE)
-               printf("Fail destroy dst_handle [%d]\n", ret);
+       mm_image_destroy_image(src_handle);
+       mm_image_destroy_image(dst_handle);
 
        return ret;
 }
@@ -434,12 +406,12 @@ static int _magick_convert_B_B_test(mm_util_color_format_e in_format, mm_util_co
                return ret;
        }
 
-       snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/convert_bb_%d_%d_%d_%d.raw", width, height, in_format, out_format);
+       snprintf(dst_path, sizeof(dst_path), "/opt/usr/home/owner/convert_bb_%u_%u_%d_%d.raw", width, height, in_format, out_format);
        printf("* Convert B B Test * input_foramt [%d], output_formt [%d] path [%s]\n", in_format, out_format, dst_path);
 
-       ret = mm_util_create_handle(&src_handle, buffer, width, height, size, format);
+       ret = mm_image_create_image(width, height, format, buffer, size, &src_handle);
        if (ret != MM_UTIL_ERROR_NONE) {
-               printf("Fail mm_util_create_handle [%d]\n", ret);
+               printf("Fail mm_image_create_image [%d]\n", ret);
                MM_UTIL_SAFE_FREE(buffer);
                return ret;
        }
@@ -452,13 +424,8 @@ static int _magick_convert_B_B_test(mm_util_color_format_e in_format, mm_util_co
 
        __save_to_file(dst_handle, dst_path);
 
-       ret = mm_util_destroy_handle(src_handle);
-       if (ret != MM_UTIL_ERROR_NONE)
-               printf("Fail destroy src_handle [%d]\n", ret);
-
-       ret = mm_util_destroy_handle(dst_handle);
-       if (ret != MM_UTIL_ERROR_NONE)
-               printf("Fail destroy dst_handle [%d]\n", ret);
+       mm_image_destroy_image(src_handle);
+       mm_image_destroy_image(dst_handle);
 
        return ret;
 }