int image_util_crop(unsigned char *dest, int x, int y, int *width, int *height, const unsigned char *src, int src_width, int src_height, image_util_colorspace_e colorspace)
{
int err = MM_UTIL_ERROR_NONE;
+ unsigned int res_w = 0;
+ unsigned int res_h = 0;
+ unsigned char *res_buffer = NULL;
+ size_t res_buffer_size = 0;
image_util_retvm_if((dest == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "dest is null");
image_util_retvm_if((src == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "src is null");
image_util_retvm_if((width == NULL || height == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "width or height is null");
image_util_retvm_if((src_width <= x || src_height <= y || src_width < x + *width || src_height < y + *height), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid crop area");
- unsigned int dest_w, dest_h;
- dest_w = *width;
- dest_h = *height;
- err = mm_util_crop_image(src, src_width, src_height, TYPECAST_COLOR(colorspace), x, y, &dest_w, &dest_h, dest);
+ err = mm_util_crop_image(src, src_width, src_height, TYPECAST_COLOR(colorspace), x, y, *width, *height, &res_buffer, &res_w, &res_h, &res_buffer_size);
if (err == MM_UTIL_ERROR_NONE) {
- *width = (int)dest_w;
- *height = (int)dest_h;
+ memcpy(dest, res_buffer, res_buffer_size);
+ *width = (int)res_w;
+ *height = (int)res_h;
}
return _image_error_capi(ERR_TYPE_TRANSFORM, err);