return IMAGE_UTIL_ERROR_NONE;
}
-static int _image_util_decode_internal(decode_s * _handle)
+static int _image_util_decode_internal(decode_s * _handle, unsigned long *res_width, unsigned long *res_height, size_t *res_size)
{
int err = MM_UTIL_ERROR_NONE;
+ unsigned long _width = 0;
+ unsigned long _height = 0;
+ size_t _size = 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");
switch (_handle->image_type) {
case IMAGE_UTIL_JPEG:
if (err == MM_UTIL_ERROR_NONE) {
*(_handle->dst_buffer) = jpeg_data.data;
- _handle->dst_size = (unsigned long long)jpeg_data.size;
- _handle->width = jpeg_data.width;
- _handle->height = jpeg_data.height;
+ _size = jpeg_data.size;
+ _width = jpeg_data.width;
+ _height = jpeg_data.height;
} else {
image_util_error("fail to decode jpeg [%d]", err);
}
if (err == MM_UTIL_ERROR_NONE) {
*(_handle->dst_buffer) = png_data.data;
- _handle->dst_size = (unsigned long long)png_data.size;
- _handle->width = png_data.width;
- _handle->height = png_data.height;
+ _size = png_data.size;
+ _width = png_data.width;
+ _height = png_data.height;
} else {
image_util_error("fail to decode png [%d]", err);
}
if (err == MM_UTIL_ERROR_NONE) {
*(_handle->dst_buffer) = gif_data.data;
- _handle->dst_size = gif_data.size;
- _handle->width = gif_data.width;
- _handle->height = gif_data.height;
+ _size = gif_data.size;
+ _width = gif_data.width;
+ _height = gif_data.height;
} else {
image_util_error("fail to decode gif [%d]", err);
}
if (err == MM_UTIL_ERROR_NONE) {
*(_handle->dst_buffer) = bmp_data.data;
- _handle->dst_size = (unsigned long long)bmp_data.size;
- _handle->width = bmp_data.width;
- _handle->height = bmp_data.height;
+ _size = bmp_data.size;
+ _width = bmp_data.width;
+ _height = bmp_data.height;
} else {
image_util_error("fail to decode bmp [%d]", err);
}
break;
}
- image_util_debug("dst_buffer(%p) width (%lu) height (%lu) dst_size (%zu)", *(_handle->dst_buffer), _handle->width, _handle->height, _handle->dst_size);
+ *res_width = _width;
+ *res_height = _height;
+ *res_size = _size;
+
+ image_util_debug("dst_buffer(%p) width (%lu) height (%lu) dst_size (%zu)", *(_handle->dst_buffer), *res_width, *res_height, *res_size);
return _image_error_capi(ERR_TYPE_DECODE, err);
}
{
int err = IMAGE_UTIL_ERROR_NONE;
decode_s *_handle = (decode_s *) handle;
+ unsigned long _width = 0;
+ unsigned long _height = 0;
+ size_t _size = 0;
IMAGE_UTIL_DECODE_HANDLE_CHECK(handle);
image_util_retvm_if((_handle->path == NULL && _handle->src_buffer == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid input");
image_util_retvm_if(_handle->dst_buffer == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid output");
- err = _image_util_decode_internal(_handle);
+ err = _image_util_decode_internal(_handle, &_width, &_height, &_size);
image_util_retvm_if(err != IMAGE_UTIL_ERROR_NONE, err, "_image_util_decode_internal failed");
- if (width)
- *width = _handle->width;
- if (height)
- *height = _handle->height;
- if (size)
- *size = _handle->dst_size;
+ *width = _width;
+ *height = _height;
+ *size = (unsigned long long)_size;
return err;
+
}
gpointer _image_util_decode_thread(gpointer data)
{
decode_s *_handle = (decode_s *) data;
int err = IMAGE_UTIL_ERROR_NONE;
+ unsigned long _width = 0;
+ unsigned long _height = 0;
+ size_t _size = 0;
image_util_fenter();
image_util_retvm_if((_handle == NULL), NULL, "Invalid Handle");
- err = _image_util_decode_internal(_handle);
+ err = _image_util_decode_internal(_handle, &_width, &_height, &_size);
if (err == IMAGE_UTIL_ERROR_NONE)
image_util_debug("Success - decode_internal");
else
if (_handle->_decode_cb) {
image_util_debug("call completed_cb");
- _handle->_decode_cb->image_decode_completed_cb(err, _handle->_decode_cb->user_data, _handle->width, _handle->height, _handle->dst_size);
+ _handle->_decode_cb->image_decode_completed_cb(err, _handle->_decode_cb->user_data, _width, _height, (unsigned long long)_size);
} else {
image_util_error("No callback");
}