- 'mm_util_img_rotate_type' and 'mm_util_magick_rotate_type' had duplicated enum type.
So we unified the type to 'mm_util_rotate_type_e'.
Change-Id: I48bf39b0b2e8731d4fa4ad3846c181a19712be99
MM_UTIL_COLOR_NUM, /**< Number of image formats */
} mm_util_color_format_e;
+/**
+ * Image rotation types
+ */
+typedef enum {
+ MM_UTIL_ROTATE_0, /**< Rotation 0 degree - no effect */
+ MM_UTIL_ROTATE_90, /**< Rotation 90 degree */
+ MM_UTIL_ROTATE_180, /**< Rotation 180 degree */
+ MM_UTIL_ROTATE_270, /**< Rotation 270 degree */
+ MM_UTIL_ROTATE_FLIP_HORZ, /**< Flip horizontal */
+ MM_UTIL_ROTATE_FLIP_VERT, /**< Flip vertial */
+ MM_UTIL_ROTATE_NUM /**< Number of rotation types */
+} mm_util_rotate_type_e;
+
typedef struct {
unsigned int width;
unsigned int height;
#include "mm_util_type.h"
-typedef enum {
- MM_UTIL_ROTATE_0, /**< Rotation 0 degree - no effect */
- MM_UTIL_ROTATE_90, /**< Rotation 90 degree */
- MM_UTIL_ROTATE_180, /**< Rotation 180 degree */
- MM_UTIL_ROTATE_270, /**< Rotation 270 degree */
- MM_UTIL_ROTATE_FLIP_HORZ, /**< Flip horizontal */
- MM_UTIL_ROTATE_FLIP_VERT, /**< Flip vertial */
- MM_UTIL_ROTATE_NUM /**< Number of rotation types */
-} mm_util_img_rotate_type;
-
int mm_util_get_image_size(mm_util_color_format_e format, unsigned int width, unsigned int height, size_t *imgsize);
int mm_util_convert_colorspace(mm_util_image_h src, mm_util_color_format_e color, mm_util_image_h *dst);
int mm_util_resize_image(mm_util_image_h src, unsigned int width, unsigned int height, mm_util_image_h *dst);
-int mm_util_rotate_image(mm_util_image_h src, mm_util_img_rotate_type angle, mm_util_image_h *dst);
+int mm_util_rotate_image(mm_util_image_h src, mm_util_rotate_type_e angle, mm_util_image_h *dst);
int mm_util_crop_image(mm_util_image_h src, unsigned int start_x, unsigned int start_y,
unsigned int width, unsigned int height, mm_util_image_h *dst);
unsigned int output_stride;
unsigned int output_elevation;
size_t buffer_size;
- mm_util_img_rotate_type angle;
+ mm_util_rotate_type_e angle;
} imgp_info_s;
/* Enumerations */
return MM_UTIL_ERROR_NONE;
}
-static int __mm_set_imgp_info_s(imgp_info_s *_imgp_info_s, mm_util_color_format_e src_format, unsigned int src_width, unsigned int src_height, mm_util_color_format_e dst_format, unsigned int dst_width, unsigned int dst_height, mm_util_img_rotate_type angle)
+static int __mm_set_imgp_info_s(imgp_info_s *_imgp_info_s, mm_util_color_format_e src_format, unsigned int src_width, unsigned int src_height, mm_util_color_format_e dst_format, unsigned int dst_width, unsigned int dst_height, mm_util_rotate_type_e angle)
{
int ret = MM_UTIL_ERROR_NONE;
return ret;
}
-int mm_util_rotate_image(mm_util_image_h src, mm_util_img_rotate_type angle, mm_util_image_h *dst)
+int mm_util_rotate_image(mm_util_image_h src, mm_util_rotate_type_e angle, mm_util_image_h *dst)
{
int ret = MM_UTIL_ERROR_NONE;
IMGPInfoFunc _mm_util_imgp_func = NULL;
#include "mm_util_type.h"
#include "mm_util_image.h"
-/**
- * Image rotation types
- */
-typedef enum {
- MM_UTIL_ROTATE_0 = 0, /**< Rotation 0 degree - no effect */
- MM_UTIL_ROTATE_90 = 90, /**< Rotation 90 degree */
- MM_UTIL_ROTATE_180 = 180, /**< Rotation 180 degree */
- MM_UTIL_ROTATE_270 = 270, /**< Rotation 270 degree */
- MM_UTIL_ROTATE_FLIP_HORZ, /**< Flip horizontal */
- MM_UTIL_ROTATE_FLIP_VERT, /**< Flip vertial */
- MM_UTIL_ROTATE_NUM /**< Number of rotation types */
-} mm_util_magick_rotate_type;
-
typedef enum {
IMG_CODEC_GIF = 0,
IMG_CODEC_PNG,
IMG_CODEC_UNKNOWN_TYPE,
} mm_util_img_codec_type;
-int mm_util_rotate_B_B(mm_util_image_h src_handle, mm_util_magick_rotate_type angle, mm_util_image_h *dst_handle);
-int mm_util_rotate_B_P(mm_util_image_h src_handle, mm_util_magick_rotate_type angle, const char *dst_path);
-int mm_util_rotate_P_B(const char *src_path, mm_util_magick_rotate_type angle, mm_util_color_format_e req_format, mm_util_image_h *dst_handle);
-int mm_util_rotate_P_P(const char *src_path, mm_util_magick_rotate_type angle, const char *dst_path);
+int mm_util_rotate_B_B(mm_util_image_h src_handle, mm_util_rotate_type_e rotation, mm_util_image_h *dst_handle);
+int mm_util_rotate_B_P(mm_util_image_h src_handle, mm_util_rotate_type_e rotation, const char *dst_path);
+int mm_util_rotate_P_B(const char *src_path, mm_util_rotate_type_e rotation, mm_util_color_format_e req_format, mm_util_image_h *dst_handle);
+int mm_util_rotate_P_P(const char *src_path, mm_util_rotate_type_e rotation, const char *dst_path);
int mm_util_resize_B_B(mm_util_image_h src_handle, unsigned int req_width, unsigned int req_height, mm_util_image_h *dst_handle);
int mm_util_resize_B_P(mm_util_image_h src_handle, unsigned int req_width, unsigned int req_height, const char *dst_path);
#include "mm_util_private.h"
#include "mm_util_magick.h"
-static bool __mm_util_check_angle(mm_util_magick_rotate_type angle);
+static bool __mm_util_check_rotation(mm_util_rotate_type_e rotation);
static void __mm_util_magick_log_method(const ExceptionType excep, const char *message)
{
return _image;
}
-static Image * __mm_util_rotate_image(Image *image, mm_util_magick_rotate_type angle)
+static Image * __mm_util_rotate_image(Image *image, mm_util_rotate_type_e rotation)
{
Image *_processed_image = NULL;
ExceptionInfo exception;
GetExceptionInfo(&exception);
- if (angle <= MM_UTIL_ROTATE_270) {
- _processed_image = RotateImage(image, angle, &exception);
- } else if (angle == MM_UTIL_ROTATE_FLIP_HORZ) {
+ switch (rotation) {
+ case MM_UTIL_ROTATE_0:
+ case MM_UTIL_ROTATE_90:
+ case MM_UTIL_ROTATE_180:
+ case MM_UTIL_ROTATE_270:
+ /*
+ RotateImage(const Image *image,const double degrees, ExceptionInfo *exception)
+ degrees: Specifies the number of degrees to rotate the image.
+ degrees is rotation multiplied by 90.
+ */
+ _processed_image = RotateImage(image, (rotation * 90), &exception);
+ break;
+ case MM_UTIL_ROTATE_FLIP_HORZ:
_processed_image = FlopImage(image, &exception);
- } else if (angle == MM_UTIL_ROTATE_FLIP_VERT) {
+ break;
+ case MM_UTIL_ROTATE_FLIP_VERT:
_processed_image = FlipImage(image, &exception);
- } else {
- mm_util_error("Invalid angle. [%d]", angle);
+ break;
+ default:
+ mm_util_error("Invalid rotation. [%d]", rotation);
+ break;
}
if (_processed_image == NULL) {
return pixels;
}
-static bool __mm_util_check_angle(mm_util_magick_rotate_type angle)
+static bool __mm_util_check_rotation(mm_util_rotate_type_e rotation)
{
- if ((angle == MM_UTIL_ROTATE_0) || (angle == MM_UTIL_ROTATE_90) || (angle == MM_UTIL_ROTATE_180) || (angle == MM_UTIL_ROTATE_270) ||
- (angle == MM_UTIL_ROTATE_FLIP_HORZ) || (angle == MM_UTIL_ROTATE_FLIP_VERT))
- return TRUE;
- else
- return FALSE;
+ switch (rotation) {
+ case MM_UTIL_ROTATE_0:
+ case MM_UTIL_ROTATE_90:
+ case MM_UTIL_ROTATE_180:
+ case MM_UTIL_ROTATE_270:
+ case MM_UTIL_ROTATE_FLIP_HORZ:
+ case MM_UTIL_ROTATE_FLIP_VERT:
+ return true;
+ default:
+ return false;
+ }
}
static int __mm_util_make_tmp_file(mm_util_img_codec_type type, char **path)
return ret;
}
-int mm_util_rotate_B_B(mm_util_image_h src_handle, mm_util_magick_rotate_type angle, mm_util_image_h *dst_handle)
+int mm_util_rotate_B_B(mm_util_image_h src_handle, mm_util_rotate_type_e rotation, mm_util_image_h *dst_handle)
{
int ret = MM_UTIL_ERROR_NONE;
mm_image_info_s *_src_handle = (mm_image_info_s*)src_handle;
void *pixels = 0;
mm_util_retvm_if(src_handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
- mm_util_retvm_if(!__mm_util_check_angle(angle), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid angle [%d]", angle);
+ mm_util_retvm_if(!__mm_util_check_rotation(rotation), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid rotation [%d]", rotation);
mm_util_retvm_if(dst_handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_handle");
- mm_util_debug("angle [%d]", angle);
+ mm_util_debug("rotation [%d]", rotation);
ret = __mm_util_get_map(_src_handle->color, &map);
mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "fail to get map");
goto ERROR;
}
- _processed_image = __mm_util_rotate_image(_image, angle);
+ _processed_image = __mm_util_rotate_image(_image, rotation);
if (_processed_image == NULL) {
mm_util_error("Error: __mm_util_rotate_image failed.");
ret = MM_UTIL_ERROR_INVALID_OPERATION;
return ret;
}
-int mm_util_rotate_B_P(mm_util_image_h src_handle, mm_util_magick_rotate_type angle, const char *dst_path)
+int mm_util_rotate_B_P(mm_util_image_h src_handle, mm_util_rotate_type_e rotation, const char *dst_path)
{
int ret = MM_UTIL_ERROR_NONE;
mm_image_info_s *_src_handle = (mm_image_info_s*)src_handle;
ExceptionInfo exception;
mm_util_retvm_if(src_handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
- mm_util_retvm_if(!__mm_util_check_angle(angle), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid angle [%d]", angle);
+ mm_util_retvm_if(!__mm_util_check_rotation(rotation), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid rotation [%d]", rotation);
mm_util_retvm_if(!MMUTIL_STRING_VALID(dst_path), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_path");
- mm_util_sec_debug("angle [%d] dst_path [%s]", angle, dst_path);
+ mm_util_sec_debug("rotation [%d] dst_path [%s]", rotation, dst_path);
ret = __mm_util_get_map(_src_handle->color, &map);
mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "fail to get map");
goto ERROR;
}
- _processed_image = __mm_util_rotate_image(_image, angle);
+ _processed_image = __mm_util_rotate_image(_image, rotation);
if (_processed_image == NULL) {
mm_util_error("Error: __mm_util_rotate_image failed.");
ret = MM_UTIL_ERROR_INVALID_OPERATION;
return ret;
}
-int mm_util_rotate_P_B(const char *src_path, mm_util_magick_rotate_type angle, mm_util_color_format_e req_format, mm_util_image_h *dst_handle)
+int mm_util_rotate_P_B(const char *src_path, mm_util_rotate_type_e rotation, mm_util_color_format_e req_format, mm_util_image_h *dst_handle)
{
int ret = MM_UTIL_ERROR_NONE;
char *map = NULL;
void *pixels = 0;
mm_util_retvm_if(!MMUTIL_STRING_VALID(src_path), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_path");
- mm_util_retvm_if(!__mm_util_check_angle(angle), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid angle [%d]", angle);
+ mm_util_retvm_if(!__mm_util_check_rotation(rotation), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid rotation [%d]", rotation);
mm_util_retvm_if(dst_handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_handle");
- mm_util_sec_debug("src_path [%s] angle [%d] req_format [%d]", src_path, angle, req_format);
+ mm_util_sec_debug("src_path [%s] rotation [%d] req_format [%d]", src_path, rotation, req_format);
ret = __mm_util_get_map(req_format, &map);
mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "fail to get map");
goto ERROR;
}
- _processed_image = __mm_util_rotate_image(_image, angle);
+ _processed_image = __mm_util_rotate_image(_image, rotation);
if (_processed_image == NULL) {
mm_util_error("Error: __mm_util_rotate_image failed.");
ret = MM_UTIL_ERROR_INVALID_OPERATION;
}
-int mm_util_rotate_P_P(const char *src_path, mm_util_magick_rotate_type angle, const char *dst_path)
+int mm_util_rotate_P_P(const char *src_path, mm_util_rotate_type_e rotation, const char *dst_path)
{
int ret = MM_UTIL_ERROR_NONE;
Image *_image = NULL;
ExceptionInfo exception;
mm_util_retvm_if(!MMUTIL_STRING_VALID(src_path), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_path");
- mm_util_retvm_if(!__mm_util_check_angle(angle), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid angle [%d]", angle);
+ mm_util_retvm_if(!__mm_util_check_rotation(rotation), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid rotation [%d]", rotation);
mm_util_retvm_if(!MMUTIL_STRING_VALID(dst_path), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_path");
- mm_util_sec_debug("src_path [%s] angle [%d] dst_path [%s]", src_path, angle, dst_path);
+ mm_util_sec_debug("src_path [%s] rotation [%d] dst_path [%s]", src_path, rotation, dst_path);
__mm_util_init(&exception);
goto ERROR;
}
- _processed_image = __mm_util_rotate_image(_image, angle);
+ _processed_image = __mm_util_rotate_image(_image, rotation);
if (_processed_image == NULL) {
mm_util_error("Error: __mm_util_rotate_image failed.");
ret = MM_UTIL_ERROR_INVALID_OPERATION;
Image *_resized_image = NULL;
Image *_rotated_image = NULL;
ExceptionInfo exception;
- mm_util_magick_rotate_type angle = MM_UTIL_ROTATE_0;
+ mm_util_rotate_type_e rotation = MM_UTIL_ROTATE_0;
mm_util_retvm_if(!MMUTIL_STRING_VALID(src_path), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src_path");
mm_util_retvm_if((req_width == 0) || (req_height == 0), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid size W[%d] H[%d]", req_width, req_height);
switch(_resized_image->orientation) {
case TopRightOrientation:
case RightTopOrientation:
- angle = MM_UTIL_ROTATE_90;
+ rotation = MM_UTIL_ROTATE_90;
break;
case BottomRightOrientation:
case RightBottomOrientation:
- angle = MM_UTIL_ROTATE_180;
+ rotation = MM_UTIL_ROTATE_180;
break;
case BottomLeftOrientation:
case LeftBottomOrientation:
- angle = MM_UTIL_ROTATE_270;
+ rotation = MM_UTIL_ROTATE_270;
break;
case TopLeftOrientation:
case LeftTopOrientation:
break;
}
- if (angle != MM_UTIL_ROTATE_0) {
- _rotated_image = __mm_util_rotate_image(_resized_image, angle);
+ if (rotation != MM_UTIL_ROTATE_0) {
+ _rotated_image = __mm_util_rotate_image(_resized_image, rotation);
if (_rotated_image == NULL) {
mm_util_error("Error: __mm_util_resize_image failed.");
ret = MM_UTIL_ERROR_INVALID_OPERATION;
#define MM_UTIL_SAFE_FREE(src) { if (src) { free(src); src = NULL; } }
-static int _magick_rotate_P_P_test(mm_util_magick_rotate_type angle);
-static int _magick_rotate_P_B_test(mm_util_magick_rotate_type angle, mm_util_color_format_e req_format);
-static int _magick_rotate_B_P_test(mm_util_magick_rotate_type angle, mm_util_color_format_e req_format);
-static int _magick_rotate_B_B_test(mm_util_magick_rotate_type angle, mm_util_color_format_e req_format);
+static int _magick_rotate_P_P_test(mm_util_rotate_type_e rotation);
+static int _magick_rotate_P_B_test(mm_util_rotate_type_e rotation, mm_util_color_format_e req_format);
+static int _magick_rotate_B_P_test(mm_util_rotate_type_e rotation, mm_util_color_format_e req_format);
+static int _magick_rotate_B_B_test(mm_util_rotate_type_e rotation, mm_util_color_format_e req_format);
static int _magick_resize_P_P_test(unsigned int req_width, unsigned int req_height);
static int _magick_resize_P_B_test(unsigned int req_width, unsigned int req_height, mm_util_color_format_e req_format);
static int _magick_resize_B_P_test(unsigned int req_width, unsigned int req_height, mm_util_color_format_e req_format);
static int _magick_convert_B_B_test(mm_util_color_format_e in_format, mm_util_color_format_e out_format);
static int _magick_resize_and_rotate_P_P_test(unsigned int req_width, unsigned int req_height);
-static char *__get_dst_path(mm_util_magick_rotate_type angle)
+static char *__get_dst_path(mm_util_rotate_type_e rotation)
{
- switch (angle) {
+ switch (rotation) {
case MM_UTIL_ROTATE_0:
return "/opt/usr/home/owner/dst_0.jpg";
case MM_UTIL_ROTATE_90:
case MM_UTIL_ROTATE_FLIP_VERT:
return "/opt/usr/home/owner/dst_V.jpg";
default:
- printf("Invalid angle\n");
+ printf("Invalid rotation\n");
return "/opt/usr/home/owner/dst_default.jpg";
}
return NULL;
}
-static char *__get_dst_raw_path(mm_util_magick_rotate_type angle)
+static char *__get_dst_raw_path(mm_util_rotate_type_e rotation)
{
- switch (angle) {
+ switch (rotation) {
case MM_UTIL_ROTATE_0:
return "/opt/usr/home/owner/dst_0.raw";
case MM_UTIL_ROTATE_90:
case MM_UTIL_ROTATE_FLIP_VERT:
return "/opt/usr/home/owner/dst_V.raw";
default:
- printf("Invalid angle\n");
+ printf("Invalid rotation\n");
return "/opt/usr/home/owner/dst_default.raw";
}
return ret;
}
-static int _magick_rotate_P_P_test(mm_util_magick_rotate_type angle)
+static int _magick_rotate_P_P_test(mm_util_rotate_type_e rotation)
{
int ret = MM_UTIL_ERROR_NONE;
char * src_path = "/opt/usr/home/owner/origin.jpg";
- printf("* Rotate P P Test * angle = [%d]* \n", angle);
+ printf("* Rotate P P Test * rotation = [%d]* \n", rotation);
- ret = mm_util_rotate_P_P(src_path, angle, __get_dst_path(angle));
+ ret = mm_util_rotate_P_P(src_path, rotation, __get_dst_path(rotation));
if (ret != MM_UTIL_ERROR_NONE)
printf("Fail mm_util_rotate_P_P [%d]\n", ret);
return ret;
}
-static int _magick_rotate_P_B_test(mm_util_magick_rotate_type angle, mm_util_color_format_e req_format)
+static int _magick_rotate_P_B_test(mm_util_rotate_type_e rotation, mm_util_color_format_e req_format)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_image_h dst_handle = NULL;
char * src_path = "/opt/usr/home/owner/origin.jpg";
- printf("* Rotate P B Test * angle = [%d] foramt = [%d] \n", angle, req_format);
+ printf("* Rotate P B Test * rotation = [%d] foramt = [%d] \n", rotation, req_format);
- ret = mm_util_rotate_P_B(src_path, angle, req_format, &dst_handle);
+ ret = mm_util_rotate_P_B(src_path, rotation, req_format, &dst_handle);
if (ret != MM_UTIL_ERROR_NONE) {
printf("Fail mm_util_rotate_P_B [%d]\n", ret);
return ret;
}
- __save_to_file(dst_handle, __get_dst_raw_path(angle));
+ __save_to_file(dst_handle, __get_dst_raw_path(rotation));
mm_image_destroy_image(dst_handle);
return ret;
}
-static int _magick_rotate_B_P_test(mm_util_magick_rotate_type angle, mm_util_color_format_e req_format)
+static int _magick_rotate_B_P_test(mm_util_rotate_type_e rotation, mm_util_color_format_e req_format)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_image_h src_handle = NULL;
size_t size = 0;
mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
- printf("* Rotate B P Test * angle = [%d] \n", angle);
+ printf("* Rotate B P Test * rotation = [%d] \n", rotation);
ret = __get_buffer_for_test(req_format, &buffer, &width, &height, &size, &format);
if (ret != MM_UTIL_ERROR_NONE) {
return ret;
}
- ret = mm_util_rotate_B_P(src_handle, angle, __get_dst_path(angle));
+ ret = mm_util_rotate_B_P(src_handle, rotation, __get_dst_path(rotation));
if (ret != MM_UTIL_ERROR_NONE)
printf("Fail mm_util_rotate_B_P [%d]\n", ret);
return ret;
}
-static int _magick_rotate_B_B_test(mm_util_magick_rotate_type angle, mm_util_color_format_e req_format)
+static int _magick_rotate_B_B_test(mm_util_rotate_type_e rotation, mm_util_color_format_e req_format)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_image_h src_handle = NULL;
size_t size = 0;
mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
- printf("* Rotate B B Test * angle = [%d] \n", angle);
+ printf("* Rotate B B Test * rotation = [%d] \n", rotation);
ret = __get_buffer_for_test(req_format, &buffer, &width, &height, &size, &format);
if (ret != MM_UTIL_ERROR_NONE) {
return ret;
}
- ret = mm_util_rotate_B_B(src_handle, angle, &dst_handle);
+ ret = mm_util_rotate_B_B(src_handle, rotation, &dst_handle);
if (ret != MM_UTIL_ERROR_NONE)
printf("Fail mm_util_rotate_B_B [%d]\n", ret);
MM_UTIL_SAFE_FREE(buffer);
- __save_to_file(dst_handle, __get_dst_raw_path(angle));
+ __save_to_file(dst_handle, __get_dst_raw_path(rotation));
mm_image_destroy_image(src_handle);
mm_image_destroy_image(dst_handle);
Name: libmm-utility
Summary: Multimedia Framework Utility Library
-Version: 0.1.41
+Version: 0.1.42
Release: 0
Group: System/Libraries
License: Apache-2.0