#include <mm_util_png.h>
#include <mm_util_gif.h>
#include <mm_util_bmp.h>
+#include <mm_util_image.h>
#include <image_util.h>
#include <image_util_private.h>
return IMAGE_UTIL_ERROR_NONE;
}
-static int __image_util_decode_internal(decode_s * _handle, unsigned int *res_width, unsigned int *res_height, size_t *res_size)
+static int __image_util_decode_internal(decode_s * _handle, mm_util_image_h *image_info)
{
int err = MM_UTIL_ERROR_NONE;
+ int colorspace = 0;
+ int downscale = 0;
+
image_util_fenter();
image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "invalid parameter");
image_util_retvm_if(_handle->dst_buffer == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid output");
- image_util_retvm_if(res_width == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid res_width");
- image_util_retvm_if(res_height == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid res_height");
- image_util_retvm_if(res_size == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid res_size");
-
- mm_image_info_s image_info;
- memset(&image_info, 0, sizeof(mm_image_info_s));
switch (_handle->image_type) {
case IMAGE_UTIL_JPEG:
{
+ colorspace = TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG);
+ downscale = _convert_decode_scale_tbl[_handle->down_scale];
+
if (_handle->path)
- err = mm_util_decode_from_jpeg_file(_handle->path, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[_handle->down_scale], &image_info);
+ err = mm_util_decode_from_jpeg_file(_handle->path, colorspace, downscale, image_info);
else
- err = mm_util_decode_from_jpeg_memory(_handle->src_buffer, _handle->src_size, TYPECAST_COLOR_BY_TYPE(_handle->colorspace, IMAGE_UTIL_JPEG), _convert_decode_scale_tbl[_handle->down_scale], &image_info);
+ err = mm_util_decode_from_jpeg_memory(_handle->src_buffer, _handle->src_size, colorspace, downscale, image_info);
}
break;
case IMAGE_UTIL_PNG:
{
if (_handle->path)
- err = mm_util_decode_from_png_file(_handle->path, &image_info);
+ err = mm_util_decode_from_png_file(_handle->path, image_info);
else
- err = mm_util_decode_from_png_memory(_handle->src_buffer, _handle->src_size, &image_info);
+ err = mm_util_decode_from_png_memory(_handle->src_buffer, _handle->src_size, image_info);
}
break;
case IMAGE_UTIL_GIF:
{
if (_handle->path)
- err = mm_util_decode_from_gif_file(_handle->path, &image_info);
+ err = mm_util_decode_from_gif_file(_handle->path, image_info);
else
- err = mm_util_decode_from_gif_memory(_handle->src_buffer, _handle->src_size, &image_info);
+ err = mm_util_decode_from_gif_memory(_handle->src_buffer, _handle->src_size, image_info);
}
break;
case IMAGE_UTIL_BMP:
{
if (_handle->path)
- err = mm_util_decode_from_bmp_file(_handle->path, &image_info);
+ err = mm_util_decode_from_bmp_file(_handle->path, image_info);
else
- err = mm_util_decode_from_bmp_memory(_handle->src_buffer, _handle->src_size, &image_info);
+ err = mm_util_decode_from_bmp_memory(_handle->src_buffer, _handle->src_size, image_info);
}
break;
default:
break;
}
- if (err == MM_UTIL_ERROR_NONE) {
- *(_handle->dst_buffer) = image_info.data;
- *res_width = image_info.width;
- *res_height = image_info.height;
- *res_size = image_info.size;
- } else {
- *(_handle->dst_buffer) = NULL;
- *res_width = 0;
- *res_height = 0;
- *res_size = 0;
- image_util_error("fail to decode image [%d]", err);
- }
-
- image_util_debug("dst_buffer(%p) width (%u) height (%u) dst_size (%zu)", *(_handle->dst_buffer), *res_width, *res_height, *res_size);
-
return _image_error_capi(err);
}
{
int err = IMAGE_UTIL_ERROR_NONE;
decode_s *_handle = (decode_s *) handle;
+ mm_util_image_h image_info = NULL;
unsigned int _width = 0;
unsigned int _height = 0;
+ unsigned char *_buffer = NULL;
size_t _size = 0;
image_util_retvm_if(_handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
image_util_retvm_if(width == NULL || height == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid width or height");
image_util_retvm_if(size == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid size");
- err = __image_util_decode_internal(_handle, &_width, &_height, &_size);
- image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "_image_util_decode_internal failed");
+ err = __image_util_decode_internal(_handle, &image_info);
+ image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "__image_util_decode_internal failed");
+
+ err = mm_image_get_image(image_info, &_width, &_height, NULL, &_buffer, &_size);
*width = (unsigned long)_width;
*height = (unsigned long)_height;
*size = (unsigned long long)_size;
+ *(_handle->dst_buffer) = _buffer;
- return err;
+ mm_image_destroy_image(image_info);
+ return _image_error_capi(err);
}
gpointer _image_util_decode_thread(gpointer data)
unsigned int _width = 0;
unsigned int _height = 0;
size_t _size = 0;
+ mm_util_image_h image_info = NULL;
+ unsigned char *_buffer = NULL;
image_util_fenter();
image_util_retvm_if((_handle == NULL), NULL, "Invalid Handle");
- err = __image_util_decode_internal(_handle, &_width, &_height, &_size);
+ err = __image_util_decode_internal(_handle, &image_info);
if (err == IMAGE_UTIL_ERROR_NONE)
image_util_debug("Success - decode_internal");
else
image_util_error("Error - decode_internal");
+ mm_image_get_image(image_info, &_width, &_height, NULL, &_buffer, &_size);
+
+ *(_handle->dst_buffer) = _buffer;
+
if (_handle->_decode_cb) {
image_util_debug("call completed_cb");
_handle->_decode_cb->image_decode_completed_cb(err, _handle->_decode_cb->user_data, (unsigned long)_width, (unsigned long)_height, (unsigned long long)_size);
image_util_error("No callback");
}
+ mm_image_destroy_image(image_info);
+
image_util_fleave();
return NULL;