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;
}