Modify image-util deprecated APIs 38/161138/5 accepted/tizen/unified/20171124.064630 submit/tizen/20171123.085544
authorJeesun Kim <iamjs.kim@samsung.com>
Wed, 22 Nov 2017 01:22:18 +0000 (10:22 +0900)
committerJongkyu Koo <jk.koo@samsung.com>
Thu, 23 Nov 2017 08:24:41 +0000 (17:24 +0900)
Change-Id: Iea8f9a321580d342b129cd6914909bcda34059eb

common/ctsvc_vcard.c
server/db/ctsvc_db_utils.c

index 01fcb0e..93cc7cb 100644 (file)
@@ -1495,9 +1495,35 @@ static bool _ctsvc_vcard_image_util_supported_jpeg_colorspace_cb(
                /* LCOV_EXCL_STOP */
        }
 
-       ret = image_util_decode_jpeg(info->src, colorspace, (unsigned char **)&buffer,
-                       &width, &height, &size_decode);
-       if (IMAGE_UTIL_ERROR_NONE != ret) {
+       image_util_decode_h dh = NULL;
+       do {
+               unsigned long l_width = 0;
+               unsigned long l_height = 0;
+               unsigned long long ll_size_decode = 0;
+
+               ret = image_util_decode_create(&dh);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_decode_set_input_path(dh, info->src);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_decode_set_colorspace(dh, colorspace);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_decode_set_output_buffer(dh, (unsigned char **)&buffer);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_decode_run(dh, &l_width, &l_height, &ll_size_decode);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+
+               width = (int)l_width;
+               height = (int)l_height;
+               size_decode = (unsigned int)ll_size_decode;
+       } while (0);
+       if (dh)
+               ret = image_util_decode_destroy(dh);
+       if (IMAGE_UTIL_ERROR_NONE != ret || 0 == width || 0 == height) {
                /* LCOV_EXCL_START */
                info->ret = CONTACTS_ERROR_SYSTEM;
                return true;
@@ -1565,8 +1591,33 @@ static bool _ctsvc_vcard_image_util_supported_jpeg_colorspace_cb(
                height = resized_height;
        }
 
-       ret = image_util_encode_jpeg_to_memory(buffer, width, height, colorspace,
-                       CTSVC_IMAGE_ENCODE_QUALITY, info->image, info->image_size);
+       image_util_encode_h eh = NULL;
+       do {
+               unsigned long long ll_size_encode = 0;
+
+               ret = image_util_encode_create(IMAGE_UTIL_JPEG, &eh);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_encode_set_input_buffer(eh, buffer);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_encode_set_resolution(eh, width, height);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_encode_set_colorspace(eh, colorspace);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_encode_set_quality(eh, CTSVC_IMAGE_ENCODE_QUALITY);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_encode_set_output_buffer(eh, info->image);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_encode_run(eh, &ll_size_encode);
+               *(info->image_size) = (unsigned int)ll_size_encode;
+       } while (0);
+       if (eh)
+               ret = image_util_encode_destroy(eh);
        free(buffer);
        if (IMAGE_UTIL_ERROR_NONE != ret) {
                /* LCOV_EXCL_START */
@@ -1586,7 +1637,7 @@ static inline int __ctsvc_vcard_encode_photo(const char *src,
        int ret;
        vcard_image_info info = {src, image, image_size, CONTACTS_ERROR_SYSTEM};
 
-       ret = image_util_foreach_supported_jpeg_colorspace(
+       ret = image_util_foreach_supported_colorspace(IMAGE_UTIL_JPEG,
                        _ctsvc_vcard_image_util_supported_jpeg_colorspace_cb, &info);
 
        if (IMAGE_UTIL_ERROR_NONE != ret)
index 575161f..ec47b21 100644 (file)
@@ -314,11 +314,39 @@ static bool _ctsvc_image_util_supported_jpeg_colorspace_cb(
                return true;
        }
 
-       ret = image_util_decode_jpeg(info->src, colorspace, (unsigned char **)&buffer,
-                       &width, &height, &size_decode);
-       if (IMAGE_UTIL_ERROR_NONE != ret) {
+       image_util_decode_h dh = NULL;
+       do {
+               unsigned long l_width = 0;
+               unsigned long l_height = 0;
+               unsigned long long ll_size_decode = 0;
+
+               ret = image_util_decode_create(&dh);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_decode_set_input_path(dh, info->src);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_decode_set_colorspace(dh, colorspace);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_decode_set_output_buffer(dh, (unsigned char **)&buffer);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_decode_run(dh, &l_width, &l_height, &ll_size_decode);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+
+               width = (int)l_width;
+               height = (int)l_height;
+               size_decode = (unsigned int)ll_size_decode;
+       } while (0);
+       if (dh)
+               ret = image_util_decode_destroy(dh);
+       if (IMAGE_UTIL_ERROR_NONE != ret || 0 == width || 0 == height) {
+               /* LCOV_EXCL_START */
                info->ret = CONTACTS_ERROR_SYSTEM;
                return true;
+               /* LCOV_EXCL_STOP */
        }
        size = (uint64_t)size_decode;
 
@@ -428,8 +456,32 @@ static bool _ctsvc_image_util_supported_jpeg_colorspace_cb(
                height = resized_height;
        }
 
-       ret = image_util_encode_jpeg(buffer, width, height, colorspace,
-                       CTSVC_IMAGE_ENCODE_QUALITY, info->dest);
+       image_util_encode_h eh = NULL;
+       do {
+               unsigned long long ll_size_encode = 0;
+
+               ret = image_util_encode_create(IMAGE_UTIL_JPEG, &eh);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_encode_set_input_buffer(eh, buffer);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_encode_set_resolution(eh, width, height);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_encode_set_colorspace(eh, colorspace);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_encode_set_quality(eh, CTSVC_IMAGE_ENCODE_QUALITY);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_encode_set_output_path(eh, info->dest);
+               if (IMAGE_UTIL_ERROR_NONE != ret)
+                       break;
+               ret = image_util_encode_run(eh, &ll_size_encode);
+       } while (0);
+       if (eh)
+               ret = image_util_encode_destroy(eh);
        free(buffer);
        if (IMAGE_UTIL_ERROR_NONE != ret) {
                /* LCOV_EXCL_START */
@@ -468,7 +520,7 @@ static int _ctsvc_image_encode(const char *src, const char *dest, int max_size)
        int ret;
        image_info info = {src, dest, max_size, CONTACTS_ERROR_SYSTEM};
 
-       ret = image_util_foreach_supported_jpeg_colorspace(
+       ret = image_util_foreach_supported_colorspace(IMAGE_UTIL_JPEG,
                        _ctsvc_image_util_supported_jpeg_colorspace_cb, &info);
 
        if (IMAGE_UTIL_ERROR_NONE != ret)