TizenRefApp-7293 Get rid of image_util_encode_jpeg() usage 09/89909/1
authorDmytro Dragan <dm.dragan@samsung.com>
Tue, 27 Sep 2016 11:16:20 +0000 (14:16 +0300)
committerDmytro Dragan <dm.dragan@samsung.com>
Tue, 27 Sep 2016 11:16:20 +0000 (14:16 +0300)
Change-Id: Ia41efe8df7addfcdc8d80c44572c3be2a047cbb0
Signed-off-by: Dmytro Dragan <dm.dragan@samsung.com>
src/Common/Utils/src/MediaUtils.cpp

index a58a7a5..e0468eb 100644 (file)
@@ -146,10 +146,31 @@ bool MediaUtils::getVideoFrame(const std::string &videoFilePath, const std::stri
     if(thumbnail)
     {
         const int quality = 90; // JPEG image quality(1 ~ 100)
-        int ret = image_util_encode_jpeg((unsigned char *)thumbnail, videoW, videoH, IMAGE_UTIL_COLORSPACE_RGB888, quality, imageFilePath.c_str());
+        image_util_encode_h encode_h = {};
+        bool isOk = false;
+        isOk = image_util_encode_create(IMAGE_UTIL_JPEG, &encode_h) == IMAGE_UTIL_ERROR_NONE;
+        if(!isOk)
+        {
+            free(thumbnail);
+            return false;
+        }
+
+        isOk &= image_util_encode_set_resolution(encode_h, videoW, videoH) == IMAGE_UTIL_ERROR_NONE;
+        isOk &= image_util_encode_set_colorspace(encode_h, IMAGE_UTIL_COLORSPACE_RGB888) == IMAGE_UTIL_ERROR_NONE;
+        isOk &= image_util_encode_set_quality(encode_h, quality) == IMAGE_UTIL_ERROR_NONE;
+        isOk &= image_util_encode_set_input_buffer(encode_h, (unsigned char *)thumbnail) == IMAGE_UTIL_ERROR_NONE;
+        isOk &= image_util_encode_set_output_path(encode_h, imageFilePath.c_str()) == IMAGE_UTIL_ERROR_NONE;
+        if(!isOk)
+        {
+            image_util_encode_destroy(encode_h);
+            free(thumbnail);
+            return false;
+        }
+
+        isOk = image_util_encode_run(encode_h, nullptr) == IMAGE_UTIL_ERROR_NONE;
+        image_util_encode_destroy(encode_h);
         free(thumbnail);
-        return ret == IMAGE_UTIL_ERROR_NONE;
-
+        return isOk;
     }
     return false;
 }