SET(submodule "image-util")
# for package file
-SET(dependents "dlog mmutil-jpeg mmutil-imgp capi-base-common capi-media-tool")
+SET(dependents "dlog mmutil-jpeg mmutil-imgp mmutil-imgcv capi-base-common capi-media-tool")
SET(pc_dependents "dlog capi-base-common capi-media-tool")
SET(fw_name "${project_prefix}-${service}-${submodule}")
* @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
*
* @pre image_util_transform_create().\n
- image_util_transform_set_crop_area().
+* image_util_transform_set_crop_area().
*
* @see image_util_transform_create()
* @see image_util_transform_destroy()
* @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
*
* @pre image_util_transform_create().\n
- image_util_transform_set_resolution().
+* image_util_transform_set_resolution().
*
* @see image_util_transform_create()
* @see image_util_transform_destroy()
* @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
*
* @pre image_util_transform_create().\n
- image_util_transform_set_rotation().
+* image_util_transform_set_rotation().
*
* @see image_util_transform_create()
* @see image_util_transform_destroy()
* @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
*
* @pre image_util_transform_create().\n
- image_util_transform_set_crop_area().
+* image_util_transform_set_crop_area().
*
* @see image_util_transform_create()
* @see image_util_transform_destroy()
*/
int image_util_encode_jpeg_to_memory(const unsigned char *image_buffer, int width, int height, image_util_colorspace_e colorspace, int quality, unsigned char **jpeg_buffer, unsigned int *jpeg_size);
+/**
+* @brief Extracts representative color from an image buffer
+* @since_tizen 3.0
+* @remarks @a image_buffer should be RGB888 colorspace.
+*
+* @param[in] image_buffer The original image buffer
+* @param[in] width The image width
+* @param[in] height The image height
+* @param[out] rgb_r The red color in RGB color space
+* @param[out] rgb_g The green color in RGB color space
+* @param[out] rgb_b The blue color in RGB color space
+*
+* @return 0 on success,
+* otherwise a negative error value
+*
+* @retval #IMAGE_UTIL_ERROR_NONE Successful
+* @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
+*
+*/
+int image_util_extract_color_from_memory(const unsigned char *image_buffer, int width, int height, unsigned char *rgb_r, unsigned char *rgb_g, unsigned char *rgb_b);
/**
Name: capi-media-image-util
Summary: A Image Utility library in Tizen Native API
-Version: 0.1.5
+Version: 0.1.6
Release: 0
Group: Multimedia/API
License: Apache-2.0
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(mmutil-jpeg)
BuildRequires: pkgconfig(mmutil-imgp)
+BuildRequires: pkgconfig(mmutil-imgcv)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(capi-media-tool)
BuildRequires: cmake
Requires: pkgconfig(mm-common)
Requires: pkgconfig(mmutil-jpeg)
Requires: pkgconfig(mmutil-imgp)
+Requires: pkgconfig(mmutil-imgcv)
Requires: pkgconfig(capi-base-common)
%description devel
#include <mm_util_imgp.h>
#include <mm_util_jpeg.h>
+#include <mm_util_imgcv.h>
#include <image_util.h>
#include <image_util_private.h>
#include <stdio.h>
int ret = IMAGE_UTIL_ERROR_INVALID_OPERATION;
char *errorstr = NULL;
switch (code) {
- case MM_UTIL_ERROR_NONE:
- ret = IMAGE_UTIL_ERROR_NONE;
- errorstr = strdup("ERROR_NONE");
- break;
- case MM_UTIL_ERROR_NO_SUCH_FILE:
- ret = IMAGE_UTIL_ERROR_NO_SUCH_FILE;
- errorstr = strdup("NO_SUCH_FILE");
- break;
- case MM_UTIL_ERROR_INVALID_PARAMETER:
- ret = IMAGE_UTIL_ERROR_INVALID_PARAMETER;
- errorstr = strdup("INVALID_PARAMETER");
- break;
- case MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT:
- ret = IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
- errorstr = strdup("NOT_SUPPORTED_FORMAT");
- break;
- case MM_UTIL_ERROR_OUT_OF_MEMORY:
- ret = IMAGE_UTIL_ERROR_OUT_OF_MEMORY;
- errorstr = strdup("OUT_OF_MEMORY");
- break;
- case MM_UTIL_ERROR_INVALID_OPERATION:
- default:
- ret = IMAGE_UTIL_ERROR_INVALID_OPERATION;
- errorstr = strdup("INVALID_OPERATION");
+ case MM_UTIL_ERROR_NONE:
+ ret = IMAGE_UTIL_ERROR_NONE;
+ errorstr = strdup("ERROR_NONE");
+ break;
+ case MM_UTIL_ERROR_NO_SUCH_FILE:
+ ret = IMAGE_UTIL_ERROR_NO_SUCH_FILE;
+ errorstr = strdup("NO_SUCH_FILE");
+ break;
+ case MM_UTIL_ERROR_INVALID_PARAMETER:
+ ret = IMAGE_UTIL_ERROR_INVALID_PARAMETER;
+ errorstr = strdup("INVALID_PARAMETER");
+ break;
+ case MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT:
+ ret = IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ errorstr = strdup("NOT_SUPPORTED_FORMAT");
+ break;
+ case MM_UTIL_ERROR_OUT_OF_MEMORY:
+ ret = IMAGE_UTIL_ERROR_OUT_OF_MEMORY;
+ errorstr = strdup("OUT_OF_MEMORY");
+ break;
+ case MM_UTIL_ERROR_INVALID_OPERATION:
+ default:
+ ret = IMAGE_UTIL_ERROR_INVALID_OPERATION;
+ errorstr = strdup("INVALID_OPERATION");
}
static image_util_error_e _image_util_error_convert(int error)
{
switch (error) {
- case MM_UTIL_ERROR_NONE:
- image_util_debug("Error None");
- return IMAGE_UTIL_ERROR_NONE;
- case MM_UTIL_ERROR_INVALID_PARAMETER:
- image_util_error("INVALID_PARAMETER(0x%08x)", IMAGE_UTIL_ERROR_INVALID_PARAMETER);
- return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
- case MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT:
- image_util_error("NOT_SUPPORTED_FORMAT(0x%08x)", IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT);
- return IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
- case MM_UTIL_ERROR_OUT_OF_MEMORY:
- image_util_error("OUT_OF_MEMORY(0x%08x)", IMAGE_UTIL_ERROR_OUT_OF_MEMORY);
- return IMAGE_UTIL_ERROR_OUT_OF_MEMORY;
- break;
- case MM_UTIL_ERROR_INVALID_OPERATION:
- default:
- image_util_error("INVALID_OPERATION(0x%08x)", error);
- return IMAGE_UTIL_ERROR_INVALID_OPERATION;
+ case MM_UTIL_ERROR_NONE:
+ image_util_debug("Error None");
+ return IMAGE_UTIL_ERROR_NONE;
+ case MM_UTIL_ERROR_INVALID_PARAMETER:
+ image_util_error("INVALID_PARAMETER(0x%08x)", IMAGE_UTIL_ERROR_INVALID_PARAMETER);
+ return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
+ case MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT:
+ image_util_error("NOT_SUPPORTED_FORMAT(0x%08x)", IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT);
+ return IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ case MM_UTIL_ERROR_OUT_OF_MEMORY:
+ image_util_error("OUT_OF_MEMORY(0x%08x)", IMAGE_UTIL_ERROR_OUT_OF_MEMORY);
+ return IMAGE_UTIL_ERROR_OUT_OF_MEMORY;
+ break;
+ case MM_UTIL_ERROR_INVALID_OPERATION:
+ default:
+ image_util_error("INVALID_OPERATION(0x%08x)", error);
+ return IMAGE_UTIL_ERROR_INVALID_OPERATION;
}
}
return _convert_image_util_error_code(__func__, err);
}
+
+int image_util_extract_color_from_memory(const unsigned char *image_buffer, int width, int height, unsigned char *rgb_r, unsigned char *rgb_g, unsigned char *rgb_b)
+{
+ int ret = MM_UTIL_ERROR_NONE;
+
+ image_util_retvm_if((image_buffer == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "image_buffer is null");
+
+ unsigned char r_color, g_color, b_color;
+ ret = mm_util_cv_extract_representative_color((void *)image_buffer, width, height, &r_color, & g_color, &b_color);
+
+ *rgb_r = r_color;
+ *rgb_g = g_color;
+ *rgb_b = b_color;
+
+ return _convert_image_util_error_code(__func__, ret);
+}
media_format_mimetype_e mimetype = -1;
switch (colorspace) {
- case IMAGE_UTIL_COLORSPACE_NV12:
- mimetype = MEDIA_FORMAT_NV12;
- break;
- case IMAGE_UTIL_COLORSPACE_NV16:
- mimetype = MEDIA_FORMAT_NV16;
- break;
- case IMAGE_UTIL_COLORSPACE_YUYV:
- mimetype = MEDIA_FORMAT_YUYV;
- break;
- case IMAGE_UTIL_COLORSPACE_UYVY:
- mimetype = MEDIA_FORMAT_UYVY;
- break;
- case IMAGE_UTIL_COLORSPACE_YUV422:
- mimetype = MEDIA_FORMAT_422P;
- break;
- case IMAGE_UTIL_COLORSPACE_I420:
- mimetype = MEDIA_FORMAT_I420;
- break;
- case IMAGE_UTIL_COLORSPACE_NV21:
- mimetype = MEDIA_FORMAT_YV12;
- break;
- case IMAGE_UTIL_COLORSPACE_RGB565:
- mimetype = MEDIA_FORMAT_RGB565;
- break;
- case IMAGE_UTIL_COLORSPACE_RGB888:
- mimetype = MEDIA_FORMAT_RGB888;
- break;
- case IMAGE_UTIL_COLORSPACE_RGBA8888:
- mimetype = MEDIA_FORMAT_RGBA;
- break;
- case IMAGE_UTIL_COLORSPACE_ARGB8888:
- mimetype = MEDIA_FORMAT_ARGB;
- break;
- case IMAGE_UTIL_COLORSPACE_BGRA8888:
- case IMAGE_UTIL_COLORSPACE_BGRX8888:
- case IMAGE_UTIL_COLORSPACE_NV61:
- default:
- mimetype = -1;
- g_printf("Not Supported Format");
- break;
+ case IMAGE_UTIL_COLORSPACE_NV12:
+ mimetype = MEDIA_FORMAT_NV12;
+ break;
+ case IMAGE_UTIL_COLORSPACE_NV16:
+ mimetype = MEDIA_FORMAT_NV16;
+ break;
+ case IMAGE_UTIL_COLORSPACE_YUYV:
+ mimetype = MEDIA_FORMAT_YUYV;
+ break;
+ case IMAGE_UTIL_COLORSPACE_UYVY:
+ mimetype = MEDIA_FORMAT_UYVY;
+ break;
+ case IMAGE_UTIL_COLORSPACE_YUV422:
+ mimetype = MEDIA_FORMAT_422P;
+ break;
+ case IMAGE_UTIL_COLORSPACE_I420:
+ mimetype = MEDIA_FORMAT_I420;
+ break;
+ case IMAGE_UTIL_COLORSPACE_NV21:
+ mimetype = MEDIA_FORMAT_YV12;
+ break;
+ case IMAGE_UTIL_COLORSPACE_RGB565:
+ mimetype = MEDIA_FORMAT_RGB565;
+ break;
+ case IMAGE_UTIL_COLORSPACE_RGB888:
+ mimetype = MEDIA_FORMAT_RGB888;
+ break;
+ case IMAGE_UTIL_COLORSPACE_RGBA8888:
+ mimetype = MEDIA_FORMAT_RGBA;
+ break;
+ case IMAGE_UTIL_COLORSPACE_ARGB8888:
+ mimetype = MEDIA_FORMAT_ARGB;
+ break;
+ case IMAGE_UTIL_COLORSPACE_BGRA8888:
+ case IMAGE_UTIL_COLORSPACE_BGRX8888:
+ case IMAGE_UTIL_COLORSPACE_NV61:
+ default:
+ mimetype = -1;
+ g_printf("Not Supported Format");
+ break;
}
g_printf("imgp fmt: %d mimetype fmt: %d", colorspace, mimetype);
int ret = 0;
if (g_handle != NULL) {
ret = image_util_transform_destroy(g_handle);
- if (ret != IMAGE_UTIL_ERROR_NONE) {
+ if (ret != IMAGE_UTIL_ERROR_NONE)
g_printf("[%d]Error image_util_transform_destroy [%d]\n", __LINE__, ret);
- } else {
+ else
g_printf("[%d]Success image_util_transform_destroy [%d]\n", __LINE__, ret);
- }
}
ret = image_util_transform_create(&g_handle);
- if (ret != IMAGE_UTIL_ERROR_NONE) {
+ if (ret != IMAGE_UTIL_ERROR_NONE)
g_printf("[%d]Error image_util_transform_create [%d]\n", __LINE__, ret);
- } else {
+ else
g_printf("[%d]Success image_util_transform_create [%d]\n", __LINE__, ret);
- }
}
static void _set_image()
g_printf("[%d]Success source packet is destroyed \n", __LINE__);
}
ret = create_media_packet();
- if (ret == MM_ERROR_NONE) {
+ if (ret == MM_ERROR_NONE)
g_printf("Success - Create_media_packet\n");
- } else {
+ else
g_printf("Error - Create_media_packet\n");
- }
}
static void _destroy()
if (g_handle) {
ret = image_util_transform_destroy(g_handle);
- if (ret != IMAGE_UTIL_ERROR_NONE) {
+ if (ret != IMAGE_UTIL_ERROR_NONE)
g_printf("[%d]Error image_util_transform_destroy [%d]\n", __LINE__, ret);
- } else {
+ else
g_printf("[%d]Success image_util_transform_destroy [%d]\n", __LINE__, ret);
- }
} else {
g_printf("[%d]Error handle was already destroyed \n", __LINE__);
}
if (!strcmp("resize", cmd)) {
width = g_width/2;
height = g_height/2;
-// width = g_width;
-// height = g_height;
ret = image_util_transform_set_resolution(g_handle, width, height);
if (ret != IMAGE_UTIL_ERROR_NONE) {