return IMAGE_UTIL_ERROR_NONE;
}
+
+#ifdef TIZEN_FEATURE_COMPATIBILITY
+int image_util_decode_jpeg(const char *path, image_util_colorspace_e colorspace, unsigned char **image_buffer, int *width, int *height, unsigned int *size)
+{
+ int err = MM_UTIL_ERROR_NONE;
+ mm_util_image_h image = NULL;
+ unsigned int image_width = 0;
+ unsigned int image_height = 0;
+ size_t image_size = 0;
+
+ image_util_warning("DEPRECATION WARNING: image_util_decode_jpeg() is removed from 5.0. Use image_util_decode_create() instead.");
+
+ image_util_retvm_if(!IMAGE_UTIL_STRING_VALID(path), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid path");
+ image_util_retvm_if(!image_buffer, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image_buffer");
+ image_util_retvm_if(!size, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "!invalid size");
+ image_util_retvm_if(!is_valid_colorspace(colorspace), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid colorspace");
+ image_util_retvm_if(!is_supported_colorspace(colorspace, IMAGE_UTIL_JPEG), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "Not supported format");
+
+ err = mm_util_decode_from_jpeg_file(path, TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG), MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1, &image);
+ image_util_retvm_if(err != MM_UTIL_ERROR_NONE, _image_error_capi(err), "mm_util_decode_from_jpeg_file failed. (%d)", err);
+
+ err = mm_image_get_image(image, &image_width, &image_height, NULL, image_buffer, &image_size);
+ if (width)
+ *width = image_width;
+ if (height)
+ *height = image_height;
+ *size = image_size;
+
+ return _image_error_capi(err);
+}
+
+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)
+{
+ int err = MM_UTIL_ERROR_NONE;
+ mm_util_image_h image = NULL;
+ unsigned int image_width = 0;
+ unsigned int image_height = 0;
+ size_t image_size = 0;
+
+ image_util_warning("DEPRECATION WARNING: image_util_decode_jpeg_from_memory() is removed from 5.0. Use image_util_decode_create() instead.");
+
+ image_util_retvm_if(!jpeg_buffer, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid jpeg_buffer");
+ image_util_retvm_if(jpeg_size <= 0, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid jpeg_size");
+ image_util_retvm_if(!image_buffer, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image_buffer");
+ image_util_retvm_if(!size, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "!invalid size");
+ image_util_retvm_if(!is_valid_colorspace(colorspace), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid colorspace");
+ image_util_retvm_if(!is_supported_colorspace(colorspace, IMAGE_UTIL_JPEG), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "Not supported format");
+
+ err = mm_util_decode_from_jpeg_memory((void *)jpeg_buffer, (size_t)jpeg_size,
+ TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG), MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1, &image);
+ image_util_retvm_if(err != MM_UTIL_ERROR_NONE, _image_error_capi(err), "mm_util_decode_from_jpeg_file failed. (%d)", err);
+
+ err = mm_image_get_image(image, &image_width, &image_height, NULL, image_buffer, &image_size);
+ if (width)
+ *width = image_width;
+ if (height)
+ *height = image_height;
+ *size = image_size;
+
+ return _image_error_capi(err);
+}
+
+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)
+{
+ int err = MM_UTIL_ERROR_NONE;
+ mm_util_image_h image = NULL;
+ unsigned int image_width = 0;
+ unsigned int image_height = 0;
+ size_t image_size = 0;
+
+ image_util_warning("DEPRECATION WARNING: image_util_decode_jpeg_with_downscale() is removed from 5.0. Use image_util_decode_create() instead.");
+
+ image_util_retvm_if(!IMAGE_UTIL_STRING_VALID(path), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid path");
+ image_util_retvm_if(!image_buffer, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image_buffer");
+ image_util_retvm_if(!size, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "!invalid size");
+ image_util_retvm_if(!is_valid_colorspace(colorspace), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid colorspace");
+ image_util_retvm_if(!is_supported_colorspace(colorspace, IMAGE_UTIL_JPEG), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "Not supported format");
+
+ err = mm_util_decode_from_jpeg_file(path, TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[downscale], &image);
+ image_util_retvm_if(err != MM_UTIL_ERROR_NONE, _image_error_capi(err), "mm_util_decode_from_jpeg_file failed. (%d)", err);
+
+ err = mm_image_get_image(image, &image_width, &image_height, NULL, image_buffer, &image_size);
+ if (width)
+ *width = image_width;
+ if (height)
+ *height = image_height;
+ *size = image_size;
+
+ return _image_error_capi(err);
+}
+
+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)
+{
+ int err = MM_UTIL_ERROR_NONE;
+ mm_util_image_h image = NULL;
+ unsigned int image_width = 0;
+ unsigned int image_height = 0;
+ size_t image_size = 0;
+
+ image_util_warning("DEPRECATION WARNING: image_util_decode_jpeg_from_memory_with_downscale() is removed from 5.0. Use image_util_decode_create() instead.");
+
+ image_util_retvm_if(!jpeg_buffer, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid jpeg_buffer");
+ image_util_retvm_if(jpeg_size <= 0, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid jpeg_size");
+ image_util_retvm_if(!image_buffer, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image_buffer");
+ image_util_retvm_if(!size, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "!invalid size");
+ image_util_retvm_if(!is_valid_colorspace(colorspace), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid colorspace");
+ image_util_retvm_if(!is_supported_colorspace(colorspace, IMAGE_UTIL_JPEG), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "Not supported format");
+
+ err = mm_util_decode_from_jpeg_memory((void *)jpeg_buffer, (size_t)jpeg_size,
+ TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[downscale], &image);
+ image_util_retvm_if(err != MM_UTIL_ERROR_NONE, _image_error_capi(err), "mm_util_decode_from_jpeg_file failed. (%d)", err);
+
+ err = mm_image_get_image(image, &image_width, &image_height, NULL, image_buffer, &image_size);
+ if (width)
+ *width = image_width;
+ if (height)
+ *height = image_height;
+ *size = image_size;
+
+ return _image_error_capi(err);
+}
+#endif
return IMAGE_UTIL_ERROR_NONE;
}
+
+#ifdef TIZEN_FEATURE_COMPATIBILITY
+int image_util_encode_jpeg(const unsigned char *buffer, int width, int height, image_util_colorspace_e colorspace, int quality, const char *path)
+{
+ int err = MM_UTIL_ERROR_NONE;
+ mm_util_image_h image = NULL;
+
+ image_util_warning("DEPRECATION WARNING: image_util_encode_jpeg() is removed from 5.0. Use image_util_encode_create() instead.");
+
+ image_util_retvm_if((path == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "path is null");
+ image_util_retvm_if((buffer == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "buffer is null");
+ image_util_retvm_if((strlen(path) == 0), IMAGE_UTIL_ERROR_NO_SUCH_FILE, "Invalid path");
+ image_util_retvm_if((is_valid_colorspace(colorspace) == FALSE), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid colorspace");
+ image_util_retvm_if((is_supported_colorspace(colorspace, IMAGE_UTIL_JPEG) == FALSE), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported format");
+
+ err = mm_image_create_image((unsigned int)width, (unsigned int)height, TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG), buffer, TEMP_DATA_SIZE, &image);
+ image_util_retvm_if(err != MM_UTIL_ERROR_NONE, _image_error_capi(err), "mm_image_create_image is failed (%d)", err);
+
+ err = mm_util_jpeg_encode_to_file(image, quality, path);
+
+ mm_image_destroy_image(image);
+
+ return _image_error_capi(err);
+}
+
+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)
+{
+ int err = MM_UTIL_ERROR_NONE;
+ mm_util_image_h image = NULL;
+
+ image_util_warning("DEPRECATION WARNING: image_util_encode_jpeg_to_memory() is removed from 5.0. Use image_util_encode_create() instead.");
+
+ image_util_retvm_if((jpeg_buffer == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "jpeg_buffer is null");
+ image_util_retvm_if((image_buffer == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "image_buffer is null");
+ image_util_retvm_if((jpeg_size == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "jpeg_size is null");
+ image_util_retvm_if((is_valid_colorspace(colorspace) == FALSE), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid colorspace");
+ image_util_retvm_if((is_supported_colorspace(colorspace, IMAGE_UTIL_JPEG) == FALSE), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported format");
+
+ err = mm_image_create_image((unsigned int)width, (unsigned int)height, TYPECAST_COLOR_BY_TYPE(colorspace, IMAGE_UTIL_JPEG), image_buffer, TEMP_DATA_SIZE, &image);
+ image_util_retvm_if(err != MM_UTIL_ERROR_NONE, _image_error_capi(err), "mm_image_create_image is failed (%d)", err);
+
+ err = mm_util_encode_to_jpeg_memory(image, quality, (void **)jpeg_buffer, jpeg_size);
+
+ mm_image_destroy_image(image);
+
+ return _image_error_capi(err);
+}
+#endif