int image_util_transform_destroy(transformation_h handle);
/**
+* @deprecated Deprecated since 3.0. Use image_util_supported_colorspace_cb() instead.
* @brief Called once for each supported JPEG encode/decode colorspace.
* @since_tizen 2.3
*
typedef bool(*image_util_supported_jpeg_colorspace_cb)(image_util_colorspace_e colorspace, void *user_data);
/**
+* @deprecated Deprecated since 3.0. Use image_util_foreach_supported_colorspace() instead.
* @brief Retrieves all supported JPEG encoding/decoding colorspace by invoking a callback function once for each one.
* @since_tizen 2.3
*
/**
+* @deprecated Deprecated since 3.0. Use image_util_decode_create() instead.
* @brief Decodes the JPEG image to the buffer.
* @since_tizen 2.3
*
int image_util_decode_jpeg(const char *path, image_util_colorspace_e colorspace, unsigned char **image_buffer, int *width, int *height, unsigned int *size);
/**
+* @deprecated Deprecated since 3.0. Use image_util_decode_create() instead.
* @brief Decodes the JPEG image(in memory) to the buffer.
* @since_tizen 2.3
*
int image_util_decode_jpeg_from_memory(const unsigned char *jpeg_buffer, int jpeg_size, image_util_colorspace_e colorspace, unsigned char **image_buffer, int *width, int *height, unsigned int *size);
/**
+* @deprecated Deprecated since 3.0. Use image_util_decode_create() instead.
* @brief Decodes the JPEG image to the buffer with downscale decoding option.
* @since_tizen 2.4
*
int image_util_decode_jpeg_with_downscale(const char *path, image_util_colorspace_e colorspace, image_util_scale_e downscale, unsigned char **image_buffer, int *width, int *height, unsigned int *size);
/**
+* @deprecated Deprecated since 3.0. Use image_util_decode_create() instead.
* @brief Decodes the JPEG image(in memory) to the buffer with downscale decoding option.
* @since_tizen 2.4
*
int image_util_decode_jpeg_from_memory_with_downscale(const unsigned char *jpeg_buffer, int jpeg_size, image_util_colorspace_e colorspace, image_util_scale_e downscale, unsigned char **image_buffer, int *width, int *height, unsigned int *size);
/**
+* @deprecated Deprecated since 3.0. Use image_util_encode_create() instead.
* @brief Encodes the image to the JPEG image.
* @since_tizen 2.3
*
int image_util_encode_jpeg(const unsigned char *buffer, int width, int height, image_util_colorspace_e colorspace, int quality, const char *path);
/**
+* @deprecated Deprecated since 3.0. Use image_util_encode_create() instead.
* @brief Encodes the image to the JPEG image
* @since_tizen 2.3
*
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);
/**
+* @brief Called once for each supported image encode/decode colorspace.
+* @since_tizen 3.0
+*
+* @param[in] colorspace The colorspace
+* @param[in] user_data The user data passed from the foreach function
+*
+* @return @c true to continue with the next iteration of the loop, \n
+* otherwise @c false to break out of the loop
+*
+* @pre image_util_foreach_supported_colorspace() invokes this callback.
+*
+* @see image_util_foreach_supported_colorspace()
+* @see image_util_encode_create()
+* @see image_util_decode_create()
+*/
+typedef bool(*image_util_supported_colorspace_cb)(image_util_colorspace_e colorspace, void *user_data);
+
+/**
+* @brief Retrieves all supported image encoding/decoding colorspace by invoking a callback function once for each one.
+* @since_tizen 3.0
+*
+* @param[in] callback The callback function to invoke
+* @param[in] user_data The user data to be passed to the callback function
+* @return 0 on success,
+* otherwise a negative error value
+*
+* @retval #IMAGE_UTIL_ERROR_NONE Successful
+* @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+*
+* @post This function invokes image_util_supported_colorspace_cb() repeatedly to retrieve each supported image encoding/decoding colorspace.
+*
+* @see image_util_supported_colorspace_cb()
+* @see image_util_encode_create()
+* @see image_util_decode_create()
+*/
+int image_util_foreach_supported_colorspace(image_util_type_e image_type, image_util_supported_colorspace_cb callback, void *user_data);
+
+/**
* @brief Creates a handle to image util decoding.
* @since_tizen 3.0
*
* @since_tizen 3.0
*
* @remarks Either image_util_decode_set_input_path() or image_util_decode_set_input_buffer() should be set.\n
-* The decoded output buffer will be RGBA format.
+* By default the decoded output buffer colorspace will be IMAGE_UTIL_COLORSPACE_RGBA8888.
+* Use image_util_decode_set_colorspace to change the colorspace.
*
* @param[in] handle The handle to image util decoding
* @param[in] dst_buffer The decoded output buffer
int image_util_decode_set_output_buffer(image_util_decode_h handle, unsigned char **dst_buffer);
/**
+* @brief Sets the decoded image colorspace format.
+* @since_tizen 3.0
+*
+* @remarks The default colorspace is IMAGE_UTIL_COLORSPACE_RGBA8888.\n
+* Use image_util_foreach_supported_colorspace to get supported colorspaces for each image format.\n
+* Errors would be returned if not supported.
+*
+* @param[in] handle The handle to image util decoding
+* @param[in] colorspace The decoded image colorspace
+*
+* @return @c 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_NOT_SUPPORTED_FORMAT Format not supported
+*
+* @pre image_util_decode_create()
+*
+* @post image_util_decode_run()/image_util_decode_run_async()
+* @post image_util_decode_destroy()
+*
+* @see image_util_supported_colorspace_cb()
+* @see image_util_foreach_supported_colorspace()
+* @see image_util_decode_create()
+* @see image_util_decode_set_input_path()
+* @see image_util_decode_set_input_buffer()
+* @see image_util_decode_set_output_buffer()
+* @see image_util_decode_run()
+* @see image_util_decode_run_async()
+* @see image_util_decode_destroy()
+*/
+int image_util_decode_set_colorspace(image_util_encode_h handle, image_util_colorspace_e colorspace);
+
+/**
+* @brief Sets the downscale value at which JPEG image should be decoded.
+* @since_tizen 3.0
+*
+* @remarks This is API is supported only for JPEG decoding.
+*
+* @param[in] handle The handle to image util decoding
+* @param[in] down_scale The downscale at which image is to be decoded
+*
+* @return @c 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_NOT_SUPPORTED_FORMAT Format not supported
+*
+* @pre image_util_decode_create()
+*
+* @post image_util_decode_run()/image_util_decode_run_async()
+* @post image_util_decode_destroy()
+*
+* @see image_util_decode_create()
+* @see image_util_decode_set_input_path()
+* @see image_util_decode_set_input_buffer()
+* @see image_util_decode_set_output_buffer()
+* @see image_util_decode_run()
+* @see image_util_decode_run_async()
+* @see image_util_decode_destroy()
+*/
+int image_util_decode_set_jpeg_downscale(image_util_encode_h handle, image_util_scale_e down_scale);
+
+/**
* @brief Starts decoding of the image and fills the output buffer set using image_util_decode_set_output_buffer().
* @since_tizen 3.0
*
int image_util_encode_set_resolution(image_util_encode_h handle, unsigned long width, unsigned long height);
/**
+* @brief Sets the colorspace format for image encoding.
+* @since_tizen 3.0
+*
+* @remarks The default colorspace is IMAGE_UTIL_COLORSPACE_RGBA8888.\n
+* Use image_util_foreach_supported_colorspace to get supported colorspaces for each image format.\n
+* Errors would be returned if not supported.
+*
+* @param[in] handle The handle to image util encoding
+* @param[in] colorspace The decoded image colorspace
+*
+* @return @c 0 on success,
+* otherwise a negative error value
+*
+* @retval #IMAGE_UTIL_ERROR_NONE Successful
+* @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
+* @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+*
+* @pre image_util_encode_create()
+*
+* @post image_util_encode_run()/image_util_encode_run_async()
+* @post image_util_encode_destroy()
+*
+* @see image_util_supported_colorspace_cb()
+* @see image_util_foreach_supported_colorspace()
+* @see image_util_encode_create()
+* @see image_util_encode_set_resolution()
+* @see image_util_encode_set_input_buffer()
+* @see image_util_encode_set_output_path()
+* @see image_util_encode_set_output_buffer()
+* @see image_util_encode_run()
+* @see image_util_encode_run_async()
+* @see image_util_encode_destroy()
+*/
+int image_util_encode_set_colorspace(image_util_encode_h handle, image_util_colorspace_e colorspace);
+
+/**
+* @brief Sets the quality for JPEG image encoding.
+* @since_tizen 3.0
+*
+* @remarks If application does not set this, then by default quality of 20 is set.
+*
+* @param[in] handle The handle to image util encoding
+* @param[in] quality Encoding quality from 1~100
+*
+* @return @c 0 on success,
+* otherwise a negative error value
+*
+* @retval #IMAGE_UTIL_ERROR_NONE Successful
+* @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
+* @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+*
+* @pre image_util_encode_create()
+*
+* @post image_util_encode_run()/image_util_encode_run_async()
+* @post image_util_encode_destroy()
+*
+* @see image_util_encode_create()
+* @see image_util_encode_set_resolution()
+* @see image_util_encode_set_input_buffer()
+* @see image_util_encode_set_output_path()
+* @see image_util_encode_set_output_buffer()
+* @see image_util_encode_run()
+* @see image_util_encode_run_async()
+* @see image_util_encode_destroy()
+*/
+int image_util_encode_set_jpeg_quality(image_util_encode_h handle, int quality);
+
+/**
* @brief Sets the compression value of png image encoding(0~9).
* @since_tizen 3.0
*
* @brief Sets the input buffer from which to encode.
* @since_tizen 3.0
*
-* @remarks Either image_util_encode_set_output_path() or image_util_encode_set_output_buffer() should be set.
-* The input buffer should be RGBA format.
+* @remarks Either image_util_encode_set_output_path() or image_util_encode_set_output_buffer() should be set.\n
+* By default the input buffer colorspace will be considered as IMAGE_UTIL_COLORSPACE_RGBA8888.\n
+* Use image_util_encode_set_colorspace to change the colorspace.
*
* @param[in] handle The handle to image util decoding
* @param[in] src_buffer The input image buffer
-1 , /* IMAGE_UTIL_COLORSPACE_NV61 */
};
+static int _convert_jpeg_colorspace_tbl[] = {
+ MM_UTIL_JPEG_FMT_YUV420 , /* IMAGE_UTIL_COLORSPACE_YUV420 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_YUV422 */
+ MM_UTIL_JPEG_FMT_YUV420 , /* IMAGE_UTIL_COLORSPACE_I420 */
+ MM_UTIL_JPEG_FMT_NV12 , /* IMAGE_UTIL_COLORSPACE_NV12 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_UYVY */
+ -1 , /* IMAGE_UTIL_COLORSPACE_YUYV */
+ -1 , /* IMAGE_UTIL_COLORSPACE_RGB565 */
+ MM_UTIL_JPEG_FMT_RGB888 , /* IMAGE_UTIL_COLORSPACE_RGB888 */
+ MM_UTIL_JPEG_FMT_ARGB8888 , /* IMAGE_UTIL_COLORSPACE_ARGB8888 */
+ MM_UTIL_JPEG_FMT_BGRA8888 , /* IMAGE_UTIL_COLORSPACE_BGRA8888 */
+ MM_UTIL_JPEG_FMT_RGBA8888 , /* IMAGE_UTIL_COLORSPACE_RGBA8888 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_BGRX8888 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_NV21 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_NV16 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_NV61 */
+};
+
+static int _convert_png_colorspace_tbl[] = {
+ -1 , /* IMAGE_UTIL_COLORSPACE_YUV420 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_YUV422 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_I420 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_NV12 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_UYVY */
+ -1 , /* IMAGE_UTIL_COLORSPACE_YUYV */
+ -1 , /* IMAGE_UTIL_COLORSPACE_RGB565 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_RGB888 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_ARGB8888 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_BGRA8888 */
+ MM_UTIL_PNG_COLOR_TYPE_RGB_ALPHA , /* IMAGE_UTIL_COLORSPACE_RGBA8888 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_BGRX8888 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_NV21 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_NV16 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_NV61 */
+};
+
+static int _convert_gif_colorspace_tbl[] = {
+ -1 , /* IMAGE_UTIL_COLORSPACE_YUV420 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_YUV422 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_I420 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_NV12 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_UYVY */
+ -1 , /* IMAGE_UTIL_COLORSPACE_YUYV */
+ -1 , /* IMAGE_UTIL_COLORSPACE_RGB565 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_RGB888 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_ARGB8888 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_BGRA8888 */
+ MM_UTIL_GIF_FMT_RGBA8888 , /* IMAGE_UTIL_COLORSPACE_RGBA8888 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_BGRX8888 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_NV21 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_NV16 */
+ -1 , /* IMAGE_UTIL_COLORSPACE_NV61 */
+};
static int _convert_decode_scale_tbl[] = {
MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1,
return _convert_image_util_error_code(__func__, ret);
}
+int image_util_foreach_supported_colorspace(image_util_type_e image_type, image_util_supported_colorspace_cb callback, void *user_data)
+{
+ int i = 0;
+
+ image_util_retvm_if((callback == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "callback is null");
+
+ switch (image_type) {
+ case IMAGE_UTIL_JPEG:
+ /* RGB has higher precedence than YUV */
+ for (i = sizeof(_convert_jpeg_colorspace_tbl) / sizeof(int) - 1; i >= 0; i--) {
+ if (_convert_jpeg_colorspace_tbl[i] != -1)
+ if (false == callback(i, user_data))
+ return IMAGE_UTIL_ERROR_NONE;
+
+ }
+ break;
+ case IMAGE_UTIL_PNG:
+ for (i = sizeof(_convert_png_colorspace_tbl) / sizeof(int) - 1; i >= 0; i--) {
+ if (_convert_png_colorspace_tbl[i] != -1)
+ if (false == callback(i, user_data))
+ return IMAGE_UTIL_ERROR_NONE;
+
+ }
+ break;
+ case IMAGE_UTIL_GIF:
+ for (i = sizeof(_convert_gif_colorspace_tbl) / sizeof(int) - 1; i >= 0; i--) {
+ if (_convert_gif_colorspace_tbl[i] != -1)
+ if (false == callback(i, user_data))
+ return IMAGE_UTIL_ERROR_NONE;
+
+ }
+ break;
+ default:
+ return MM_UTIL_ERROR_INVALID_PARAMETER;
+ }
+
+ return IMAGE_UTIL_ERROR_NONE;
+}
+
+static int _image_util_decode_create_jpeg_handle(decode_encode_s * handle)
+{
+ int err = MM_UTIL_ERROR_NONE;
+
+ image_util_retvm_if((handle == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
+
+ mm_util_jpeg_yuv_data *_handle = (mm_util_jpeg_yuv_data *) calloc(1, sizeof(mm_util_jpeg_yuv_data));
+ image_util_retvm_if((_handle == NULL), MM_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY(0x%08x)", MM_UTIL_ERROR_OUT_OF_MEMORY);
+
+ handle->image_h = (MMHandleType) _handle;
+ handle->colorspace = IMAGE_UTIL_COLORSPACE_RGBA8888;
+ handle->down_scale = sizeof(_convert_decode_scale_tbl);
+
+ return err;
+}
+
static int _image_util_decode_create_png_handle(decode_encode_s * handle)
{
int err = MM_UTIL_ERROR_NONE;
_handle->is_decode = TRUE;
switch (image_type) {
+ case IMAGE_UTIL_JPEG:
+ err = _image_util_decode_create_jpeg_handle(_handle);
+ break;
case IMAGE_UTIL_PNG:
err = _image_util_decode_create_png_handle(_handle);
break;
return err;
}
+int image_util_decode_set_colorspace(image_util_encode_h handle, image_util_colorspace_e colorspace)
+{
+ int err = IMAGE_UTIL_ERROR_NONE;
+ decode_encode_s *_handle = (decode_encode_s *) handle;
+
+ if (_handle == NULL || _handle->is_decode == FALSE) {
+ image_util_error("Invalid Handle");
+ return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
+ }
+
+ image_util_retvm_if((colorspace < 0 || colorspace >= sizeof(image_util_colorspace_e) / sizeof(int)), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid colorspace");
+ switch (_handle->image_type) {
+ case IMAGE_UTIL_JPEG:
+ image_util_retvm_if((_convert_jpeg_colorspace_tbl[colorspace] == -1), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported format");
+ break;
+ case IMAGE_UTIL_PNG:
+ image_util_retvm_if((_convert_png_colorspace_tbl[colorspace] == -1), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported format");
+ break;
+ case IMAGE_UTIL_GIF:
+ image_util_retvm_if((_convert_gif_colorspace_tbl[colorspace] == -1), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported format");
+ break;
+ default:
+ image_util_error("Invalid image type");
+ return MM_UTIL_ERROR_INVALID_PARAMETER;
+ }
+
+ _handle->colorspace = colorspace;
+
+ return err;
+}
+
+int image_util_decode_set_jpeg_downscale(image_util_encode_h handle, image_util_scale_e down_scale)
+{
+ int err = IMAGE_UTIL_ERROR_NONE;
+ decode_encode_s *_handle = (decode_encode_s *) handle;
+
+ if (_handle == NULL || _handle->is_decode == FALSE) {
+ image_util_error("Invalid Handle");
+ return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
+ }
+ if (_handle->image_type != IMAGE_UTIL_JPEG) {
+ image_util_error("Wrong image format");
+ return IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ }
+ image_util_retvm_if((down_scale < 0 || down_scale >= sizeof(_convert_decode_scale_tbl) / sizeof(int)), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "downscale is invalid");
+
+ _handle->down_scale = down_scale;
+
+ return err;
+}
+
static int _image_util_decode_internal(decode_encode_s * _handle)
{
int err = MM_UTIL_ERROR_NONE;
switch (_handle->image_type) {
+ case IMAGE_UTIL_JPEG:
+ {
+ mm_util_jpeg_yuv_data *jpeg_data;
+
+ jpeg_data = (mm_util_jpeg_yuv_data *) _handle->image_h;
+ if (jpeg_data == NULL) {
+ image_util_error("Invalid jpeg data");
+ return MM_UTIL_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_handle->path) {
+ if (_handle->down_scale < sizeof(_convert_decode_scale_tbl))
+ err = mm_util_decode_from_jpeg_file_with_downscale(jpeg_data, _handle->path, _convert_jpeg_colorspace_tbl[_handle->colorspace], _convert_decode_scale_tbl[_handle->down_scale]);
+ else
+ err = mm_util_decode_from_jpeg_file(jpeg_data, _handle->path, _convert_jpeg_colorspace_tbl[_handle->colorspace]);
+ }
+ else {
+ if (_handle->down_scale < sizeof(_convert_decode_scale_tbl))
+ err = mm_util_decode_from_jpeg_memory_with_downscale(jpeg_data, _handle->src_buffer, _handle->src_size, _convert_jpeg_colorspace_tbl[_handle->colorspace], _convert_decode_scale_tbl[_handle->down_scale]);
+ else
+ err = mm_util_decode_from_jpeg_memory(jpeg_data, _handle->src_buffer, _handle->src_size, _convert_jpeg_colorspace_tbl[_handle->colorspace]);
+ }
+
+ if (err == MM_UTIL_ERROR_NONE) {
+ *(_handle->dst_buffer) = jpeg_data->data;
+ _handle->dst_size = jpeg_data->size;
+ _handle->width = jpeg_data->width;
+ _handle->height = jpeg_data->height;
+ }
+ }
+ break;
case IMAGE_UTIL_PNG:
{
mm_util_png_data *png_data;
}
switch (_handle->image_type) {
+ case IMAGE_UTIL_JPEG:
+ {
+ mm_util_jpeg_yuv_data *jpeg_data;
+
+ jpeg_data = (mm_util_jpeg_yuv_data *) _handle->image_h;
+ if (jpeg_data == NULL) {
+ image_util_error("Invalid jpeg data");
+ return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
+ }
+ IMAGE_UTIL_SAFE_FREE(jpeg_data);
+ }
+ break;
case IMAGE_UTIL_PNG:
{
mm_util_png_data *png_data;
return err;
}
+static int _image_util_encode_create_jpeg_handle(decode_encode_s * handle)
+{
+ int err = MM_UTIL_ERROR_NONE;
+
+ image_util_retvm_if((handle == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
+
+ mm_util_jpeg_yuv_data *_handle = (mm_util_jpeg_yuv_data *) calloc(1, sizeof(mm_util_jpeg_yuv_data));
+ image_util_retvm_if((_handle == NULL), MM_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY(0x%08x)", MM_UTIL_ERROR_OUT_OF_MEMORY);
+
+ handle->image_h = (MMHandleType) _handle;
+ handle->colorspace = IMAGE_UTIL_COLORSPACE_RGBA8888;
+ handle->quality = 20;
+
+ return err;
+}
+
static int _image_util_encode_create_png_handle(decode_encode_s * handle)
{
int err = MM_UTIL_ERROR_NONE;
_handle->is_decode = FALSE;
switch (image_type) {
+ case IMAGE_UTIL_JPEG:
+ err = _image_util_encode_create_jpeg_handle(_handle);
+ break;
case IMAGE_UTIL_PNG:
err = _image_util_encode_create_png_handle(_handle);
break;
image_util_retvm_if((_image_util_check_resolution(width, height) == false), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid resolution");
switch (_handle->image_type) {
+ case IMAGE_UTIL_JPEG:
+ {
+ mm_util_jpeg_yuv_data *jpeg_data;
+
+ jpeg_data = (mm_util_jpeg_yuv_data *) _handle->image_h;
+ if (jpeg_data == NULL) {
+ image_util_error("Invalid jpeg data");
+ return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
+ }
+ jpeg_data->width = width;
+ jpeg_data->height = height;
+ }
+ break;
case IMAGE_UTIL_PNG:
{
mm_util_png_data *png_data;
return err;
}
+int image_util_encode_set_colorspace(image_util_encode_h handle, image_util_colorspace_e colorspace)
+{
+ int err = IMAGE_UTIL_ERROR_NONE;
+ decode_encode_s *_handle = (decode_encode_s *) handle;
+
+ if (_handle == NULL || _handle->is_decode == TRUE) {
+ image_util_error("Invalid Handle");
+ return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
+ }
+
+ image_util_retvm_if((colorspace < 0 || colorspace >= sizeof(image_util_colorspace_e) / sizeof(int)), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid colorspace");
+ switch (_handle->image_type) {
+ case IMAGE_UTIL_JPEG:
+ image_util_retvm_if((_convert_jpeg_colorspace_tbl[colorspace] == -1), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported format");
+ break;
+ case IMAGE_UTIL_PNG:
+ image_util_retvm_if((_convert_png_colorspace_tbl[colorspace] == -1), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported format");
+ break;
+ case IMAGE_UTIL_GIF:
+ image_util_retvm_if((_convert_gif_colorspace_tbl[colorspace] == -1), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported format");
+ break;
+ default:
+ image_util_error("Invalid image type");
+ return MM_UTIL_ERROR_INVALID_PARAMETER;
+ }
+
+ _handle->colorspace = colorspace;
+
+ return err;
+}
+
+int image_util_encode_set_jpeg_quality(image_util_encode_h handle, int quality)
+{
+ int err = IMAGE_UTIL_ERROR_NONE;
+ decode_encode_s *_handle = (decode_encode_s *) handle;
+
+ if (_handle == NULL || _handle->is_decode == TRUE) {
+ image_util_error("Invalid Handle");
+ return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
+ }
+ if (_handle->image_type != IMAGE_UTIL_JPEG) {
+ image_util_error("Wrong image format");
+ return IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+ }
+ image_util_retvm_if((quality <= 0 || quality > 100), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid quality");
+
+ _handle->quality = quality;
+
+ return err;
+}
+
int image_util_encode_set_png_compression(image_util_encode_h handle, image_util_png_compression_e compression)
{
int err = IMAGE_UTIL_ERROR_NONE;
image_util_error("Wrong image format");
return IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
}
+ image_util_retvm_if((compression < IMAGE_UTIL_PNG_COMPRESSION_0 || compression > IMAGE_UTIL_PNG_COMPRESSION_9), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid compression value");
+
png_data = (mm_util_png_data *) _handle->image_h;
if (png_data == NULL) {
image_util_error("Invalid png data");
int err = MM_UTIL_ERROR_NONE;
switch (_handle->image_type) {
+ case IMAGE_UTIL_JPEG:
+ {
+ if (_handle->path)
+ err = mm_util_jpeg_encode_to_file (_handle->path, _handle->src_buffer, _handle->width, _handle->height, _convert_jpeg_colorspace_tbl[_handle->colorspace], _handle->quality);
+ else
+ err = mm_util_jpeg_encode_to_memory (_handle->dst_buffer, (int *)&(_handle->dst_size), _handle->src_buffer, _handle->width, _handle->height, _convert_jpeg_colorspace_tbl[_handle->colorspace], _handle->quality);
+ }
+ break;
case IMAGE_UTIL_PNG:
{
mm_util_png_data *png_data;
}
switch (_handle->image_type) {
+ case IMAGE_UTIL_JPEG:
+ {
+ mm_util_jpeg_yuv_data *jpeg_data;
+
+ jpeg_data = (mm_util_jpeg_yuv_data *) _handle->image_h;
+ if (jpeg_data == NULL) {
+ image_util_error("Invalid jpeg data");
+ return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
+ }
+ IMAGE_UTIL_SAFE_FREE(jpeg_data);
+ }
+ break;
case IMAGE_UTIL_PNG:
{
mm_util_png_data *png_data;