From 84b550040d8aff07be5b8dd864b153e62f5986c8 Mon Sep 17 00:00:00 2001 From: hj kim Date: Mon, 19 Feb 2018 19:12:20 +0900 Subject: [PATCH] Apply new mm_util_crop_image() Change-Id: I094f22e9c8a35c416e7587778fbc39654a78cf00 --- packaging/capi-media-image-util.spec | 2 +- src/image_util_internal.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packaging/capi-media-image-util.spec b/packaging/capi-media-image-util.spec index c761767..1c31cbc 100755 --- a/packaging/capi-media-image-util.spec +++ b/packaging/capi-media-image-util.spec @@ -1,6 +1,6 @@ Name: capi-media-image-util Summary: A Image Utility library in Tizen Native API -Version: 0.1.32 +Version: 0.1.33 Release: 2 Group: Multimedia/API License: Apache-2.0 diff --git a/src/image_util_internal.c b/src/image_util_internal.c index afdd779..771574a 100755 --- a/src/image_util_internal.c +++ b/src/image_util_internal.c @@ -79,6 +79,10 @@ int image_util_rotate(unsigned char *dest, int *dest_width, int *dest_height, im 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"); @@ -86,13 +90,11 @@ int image_util_crop(unsigned char *dest, int x, int y, int *width, int *height, 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); -- 2.7.4