From d7b71cb79db6811886eb6c480544c7ddf705136b Mon Sep 17 00:00:00 2001 From: "jiyong.min" Date: Wed, 9 Sep 2020 11:59:31 +0900 Subject: [PATCH] Fix incorrect parameters for cropping image - Problem: rotate_image with odd width/height image return error. - Cause: Cropping image for odd width/height image has incorrect parameters. - Solution: The start_x, start_y should be used for sx, sy of cropping image. Change-Id: I8003dac4392823666bac98fa8a30771f367013e3 --- imgp/mm_util_imgp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/imgp/mm_util_imgp.c b/imgp/mm_util_imgp.c index 1109c37..807bd11 100644 --- a/imgp/mm_util_imgp.c +++ b/imgp/mm_util_imgp.c @@ -678,11 +678,11 @@ int mm_util_rotate_image(mm_util_image_h src, mm_util_rotate_type_e angle, mm_ut unsigned int start_x = 0; unsigned int start_y = 0; if (angle == MM_UTIL_ROTATE_90) { - start_x = 0; + start_x = _imgp_info_s->output_stride - _imgp_info_s->dst_width; start_y = 0; } else if (angle == MM_UTIL_ROTATE_180) { - start_x = _imgp_info_s->output_stride-_imgp_info_s->dst_width; - start_y = 0; + start_x = _imgp_info_s->output_stride - _imgp_info_s->dst_width; + start_y = _imgp_info_s->output_elevation - _imgp_info_s->dst_height; } else if (angle == MM_UTIL_ROTATE_270) { start_x = 0; start_y = _imgp_info_s->output_elevation - _imgp_info_s->dst_height; @@ -694,7 +694,7 @@ int mm_util_rotate_image(mm_util_image_h src, mm_util_rotate_type_e angle, mm_ut goto ERROR; } - ret = mm_util_crop_image(_rotate_image, 0, 0, start_x, start_y, dst); + ret = mm_util_crop_image(_rotate_image, start_x, start_y, _imgp_info_s->dst_width, _imgp_info_s->dst_height, dst); mm_image_destroy_image(_rotate_image); if (ret != MM_UTIL_ERROR_NONE) { mm_util_error("mm_util_crop_image failed"); -- 2.7.4