} while (0)
-#define IMAGE_UTIL_STRING_VALID(str) \
+#define IMAGE_UTIL_STRING_VALID(str) \
((str != NULL && strlen(str) > 0) ? true : false)
-#define IMAGE_UTIL_SAFE_G_FREE(src) { if (src) {g_free(src); src = NULL; } }
+#define IMAGE_UTIL_SAFE_G_FREE(src) { if (src) {g_free(src); src = NULL; } }
+#define _NOT_SUPPORTED_COLORSPACE (-1)
-#define _NOT_SUPPORTED_COLORSPACE (-1)
+#define IMGCV_FUNC_NAME "mm_util_cv_extract_representative_color"
+#define PATH_MMUTIL_IMGCV_LIB PATH_LIBDIR"/libmmutil_imgcv.so"
-#define IMGCV_FUNC_NAME "mm_util_cv_extract_representative_color"
-#define PATH_MMUTIL_IMGCV_LIB PATH_LIBDIR"/libmmutil_imgcv.so"
+#define TYPECAST_COLOR(c) _convert_type_of_colorspace(c)
+#define TYPECAST_COLOR_BY_TYPE(c, t) _convert_type_of_colorspace_with_image_type(c, t)
+#define TYPECAST_IMAGE_CODEC(t) _convert_image_codec(t)
-#define TYPECAST_COLOR(c) _convert_type_of_colorspace(c)
-#define TYPECAST_COLOR_BY_TYPE(c, t) _convert_type_of_colorspace_with_image_type(c, t)
-
-#define NUM_OF_COLORSPACE _get_number_of_colorspace()
+#define NUM_OF_COLORSPACE _get_number_of_colorspace()
typedef struct {
/* for converting colorspace */
unsigned int _get_number_of_colorspace(void);
int _convert_type_of_colorspace(const image_util_colorspace_e colorspace);
int _convert_type_of_colorspace_with_image_type(const image_util_colorspace_e colorspace, const image_util_type_e type);
+int _convert_image_codec(image_util_type_e type);
int _check_encode_path(const char *path);
int _image_error_capi(int error_code);
Name: capi-media-image-util
Summary: A Image Utility library in Tizen Native API
-Version: 0.4.0
+Version: 0.4.1
Release: 0
Group: Multimedia/API
License: Apache-2.0
return _image_error_capi(err);
}
- err = mm_util_enc_opt_set_codec(_handle->enc_opt, image_type);
+ err = mm_util_enc_opt_set_codec(_handle->enc_opt, TYPECAST_IMAGE_CODEC(image_type));
if (err != MM_UTIL_ERROR_NONE) {
image_util_error("Error - mm_util_enc_opt_set_codec is failed (%d)", err);
image_util_encode_destroy(_handle);
int _convert_type_of_colorspace_with_image_type(const image_util_colorspace_e colorspace, const image_util_type_e type)
{
- int new_colorspace = _NOT_SUPPORTED_COLORSPACE;
-
if (!_is_valid_colorspace(colorspace))
return _NOT_SUPPORTED_COLORSPACE;
switch (type) {
case IMAGE_UTIL_JPEG:
- new_colorspace = _convert_jpeg_colorspace_tbl[colorspace];
- break;
+ return _convert_jpeg_colorspace_tbl[colorspace];
case IMAGE_UTIL_PNG:
- new_colorspace = _convert_png_colorspace_tbl[colorspace];
- break;
+ return _convert_png_colorspace_tbl[colorspace];
case IMAGE_UTIL_GIF:
- new_colorspace = _convert_gif_colorspace_tbl[colorspace];
- break;
+ return _convert_gif_colorspace_tbl[colorspace];
case IMAGE_UTIL_BMP:
- new_colorspace = _convert_bmp_colorspace_tbl[colorspace];
- break;
+ return _convert_bmp_colorspace_tbl[colorspace];
case IMAGE_UTIL_WEBP:
- new_colorspace = _convert_webp_colorspace_tbl[colorspace];
- break;
+ return _convert_webp_colorspace_tbl[colorspace];
case IMAGE_UTIL_HEIF:
- new_colorspace = _convert_heif_colorspace_tbl[colorspace];
- break;
+ return _convert_heif_colorspace_tbl[colorspace];
case IMAGE_UTIL_JPEG_XL:
- new_colorspace = _convert_jxl_colorspace_tbl[colorspace];
- break;
+ return _convert_jxl_colorspace_tbl[colorspace];
default:
image_util_error("Invalid image type");
}
- return new_colorspace;
+ return _NOT_SUPPORTED_COLORSPACE;
+}
+
+int _convert_image_codec(image_util_type_e type)
+{
+ switch (type) {
+ case IMAGE_UTIL_JPEG:
+ return IMG_CODEC_JPEG;
+ case IMAGE_UTIL_PNG:
+ return IMG_CODEC_PNG;
+ case IMAGE_UTIL_GIF:
+ return IMG_CODEC_GIF;
+ case IMAGE_UTIL_BMP:
+ return IMG_CODEC_BMP;
+ case IMAGE_UTIL_WEBP:
+ return IMG_CODEC_WEBP;
+ case IMAGE_UTIL_HEIF:
+ return IMG_CODEC_HEIF;
+ case IMAGE_UTIL_JPEG_XL:
+ return IMG_CODEC_JPEGXL;
+ default:
+ image_util_error("Invalid image type %u", type);
+ }
+
+ return IMG_CODEC_UNKNOWN_TYPE;
}
int _check_encode_path(const char *path)