Unify rotate type enum 71/232371/3 accepted/tizen/unified/20200507.052254 submit/tizen/20200506.063025
authorjiyong.min <jiyong.min@samsung.com>
Sun, 3 May 2020 22:23:57 +0000 (07:23 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Tue, 5 May 2020 23:07:03 +0000 (08:07 +0900)
Change-Id: I1d186ea40c90cb449b9f4af6dc93a4678007dc87

libdcm-util/dcm_image_codec.c

index ab2f8eae98a40beeaa26415dca5db4d51ebd3714..9fd7bb8e64bbb593c3e79da9c76edb602a7ff59f 100755 (executable)
@@ -67,7 +67,7 @@ int dcm_decode_image(const char *file_path, const int orientation, const gboolea
        unsigned int resized_width = 0;
        unsigned int resized_height = 0;
        mm_util_img_codec_type type = IMG_CODEC_UNKNOWN_TYPE;
-       mm_util_magick_rotate_type angle = MM_UTIL_ROTATE_NUM;
+       mm_util_rotate_type_e rotation = MM_UTIL_ROTATE_NUM;
        mm_util_image_h resize_dst_handle = NULL;
        mm_util_image_h dst_handle = NULL;
        mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
@@ -76,20 +76,28 @@ int dcm_decode_image(const char *file_path, const int orientation, const gboolea
 
        DCM_CHECK_VAL(file_path, MS_MEDIA_ERR_INVALID_PARAMETER);
 
-       if (orientation == NOT_AVAILABLE || orientation == NORMAL)
-               angle = MM_UTIL_ROTATE_0;
-       else if (orientation == ROT_90)
-               angle = MM_UTIL_ROTATE_90;
-       else if (orientation == ROT_180)
-               angle = MM_UTIL_ROTATE_180;
-       else if (orientation == ROT_270)
-               angle = MM_UTIL_ROTATE_270;
-       else if (orientation == HFLIP)
-               angle = MM_UTIL_ROTATE_FLIP_HORZ;
-       else if (orientation == VFLIP)
-               angle = MM_UTIL_ROTATE_FLIP_VERT;
-       else {
-               dcm_error("Not supported angle [%d]", orientation);
+       switch(orientation) {
+       case NOT_AVAILABLE:
+       case NORMAL:
+               rotation = MM_UTIL_ROTATE_0;
+               break;
+       case ROT_90:
+               rotation = MM_UTIL_ROTATE_90;
+               break;
+       case ROT_180:
+               rotation = MM_UTIL_ROTATE_180;
+               break;
+       case ROT_270:
+               rotation = MM_UTIL_ROTATE_270;
+               break;
+       case HFLIP:
+               rotation = MM_UTIL_ROTATE_FLIP_HORZ;
+               break;
+       case VFLIP:
+               rotation = MM_UTIL_ROTATE_FLIP_VERT;
+               break;
+       default:
+               dcm_error("Not supported rotation [%d]", orientation);
                return MS_MEDIA_ERR_INTERNAL;
        }
 
@@ -108,14 +116,14 @@ int dcm_decode_image(const char *file_path, const int orientation, const gboolea
                                goto ERROR;
                        }
 
-                       ret = mm_util_rotate_B_B(resize_dst_handle, angle, &dst_handle);
+                       ret = mm_util_rotate_B_B(resize_dst_handle, rotation, &dst_handle);
                        if (ret != MM_UTIL_ERROR_NONE) {
                                dcm_error("Failed to rotate image!err: %d", ret);
                                ret = MS_MEDIA_ERR_INTERNAL;
                                goto ERROR;
                        }
                } else {
-                       ret = mm_util_rotate_P_B(file_path, angle, MM_UTIL_COLOR_RGBA, &dst_handle);
+                       ret = mm_util_rotate_P_B(file_path, rotation, MM_UTIL_COLOR_RGBA, &dst_handle);
                        if (ret != MM_UTIL_ERROR_NONE) {
                                dcm_error("Failed to rotate image buffer! err: %d", ret);
                                ret = MS_MEDIA_ERR_INTERNAL;
@@ -123,7 +131,7 @@ int dcm_decode_image(const char *file_path, const int orientation, const gboolea
                        }
                }
        } else {
-               ret = mm_util_rotate_P_B(file_path, angle, MM_UTIL_COLOR_RGBA, &dst_handle);
+               ret = mm_util_rotate_P_B(file_path, rotation, MM_UTIL_COLOR_RGBA, &dst_handle);
                if (ret != MM_UTIL_ERROR_NONE) {
                        dcm_error("Failed to rotate image buffer! err: %d", ret);
                        ret = MS_MEDIA_ERR_INTERNAL;
@@ -135,10 +143,8 @@ int dcm_decode_image(const char *file_path, const int orientation, const gboolea
 
 ERROR:
 
-       if (resize_dst_handle)
-               mm_image_destroy_image(resize_dst_handle);
-       if (dst_handle)
-               mm_image_destroy_image(dst_handle);
+       mm_image_destroy_image(resize_dst_handle);
+       mm_image_destroy_image(dst_handle);
 
        dcm_debug_fleave();