ROT_270 = 8
} dcm_exif_orientation_e;
-static bool __dcm_get_optimized_wh(unsigned int src_width, unsigned int src_height, unsigned int *calc_width, unsigned int *calc_height)
-{
- *calc_width = 0;
- *calc_height = 0;
-
- if (src_width <= OPT_IMAGE_WIDTH && src_height <= OPT_IMAGE_HEIGHT) {
- dcm_debug("Original image is smaller than target image");
- *calc_width = src_width;
- *calc_height = src_height;
- return FALSE;
- }
-
- if (src_width > src_height) {
- *calc_width = OPT_IMAGE_WIDTH;
- *calc_height = (int)(src_height * (((double) OPT_IMAGE_WIDTH) / ((double) src_width)));
- } else {
- *calc_width = (int)(src_width * (((double) OPT_IMAGE_HEIGHT) / ((double) src_height)));
- *calc_height = OPT_IMAGE_HEIGHT;
- }
-
- return TRUE;
-}
-
-int dcm_decode_image(const char *file_path, const int orientation, const gboolean resize, unsigned char **image_buffer, size_t *size,
+int dcm_decode_image(const char *file_path, const int orientation, unsigned char **image_buffer, size_t *size,
unsigned int *buff_width, unsigned int *buff_height)
{
int ret = MS_MEDIA_ERR_NONE;
- unsigned int width = 0;
- unsigned int height = 0;
- unsigned int resized_width = 0;
- unsigned int resized_height = 0;
- mm_util_img_codec_type type = IMG_CODEC_UNKNOWN_TYPE;
mm_util_rotate_type_e rotation = MM_UTIL_ROTATE_NUM;
- mm_util_image_h resize_dst_handle = NULL;
mm_util_image_h dst_handle = NULL;
mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
return MS_MEDIA_ERR_INTERNAL;
}
- if (resize) {
- /* Get the optimized width/height to enhance performance for big size image */
- ret = mm_util_extract_image_info(file_path, &type, &width, &height);
- if (ret != MM_UTIL_ERROR_NONE)
- dcm_error("Failed to get image info!err: %d", ret);
-
- if (__dcm_get_optimized_wh(width, height, &resized_width, &resized_height)) {
- /* Resize the big size image to enhance performance for big size image */
- ret = mm_util_resize_P_B(file_path, resized_width, resized_height, MM_UTIL_COLOR_RGBA, &resize_dst_handle);
- if (ret != MM_UTIL_ERROR_NONE) {
- dcm_error("Failed to resize image!err: %d", ret);
- ret = MS_MEDIA_ERR_INTERNAL;
- goto ERROR;
- }
-
- ret = mm_util_rotate_B_B(resize_dst_handle, rotation, &dst_handle);
- if (ret != MM_UTIL_ERROR_NONE) {
- dcm_error("Failed to rotate image!err: %d", ret);
- ret = MS_MEDIA_ERR_INTERNAL;
- goto ERROR;
- }
- } else {
- ret = mm_util_rotate_P_B(file_path, rotation, MM_UTIL_COLOR_RGBA, &dst_handle);
- if (ret != MM_UTIL_ERROR_NONE) {
- dcm_error("Failed to rotate image buffer! err: %d", ret);
- ret = MS_MEDIA_ERR_INTERNAL;
- goto ERROR;
- }
- }
- } else {
- ret = mm_util_rotate_P_B(file_path, rotation, MM_UTIL_COLOR_RGBA, &dst_handle);
- if (ret != MM_UTIL_ERROR_NONE) {
- dcm_error("Failed to rotate image buffer! err: %d", ret);
- ret = MS_MEDIA_ERR_INTERNAL;
- goto ERROR;
- }
+ ret = mm_util_rotate_P_B(file_path, rotation, MM_UTIL_COLOR_RGBA, &dst_handle);
+ if (ret != MM_UTIL_ERROR_NONE) {
+ dcm_error("Failed to rotate image buffer! err: %d", ret);
+ return MS_MEDIA_ERR_INTERNAL;
}
mm_image_get_image(dst_handle, buff_width, buff_height, &format, image_buffer, size);
-
-ERROR:
-
- mm_image_destroy_image(resize_dst_handle);
mm_image_destroy_image(dst_handle);
dcm_debug_fleave();