int image_util_rotate(unsigned char *dest, int *dest_width, int *dest_height, image_util_rotation_e dest_rotation, 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((dest_rotation < 0 || dest_rotation > IMAGE_UTIL_ROTATION_FLIP_VERT), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid rotation");
image_util_retvm_if((dest_width == NULL || dest_height == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "dest_width or dest_height is null");
- unsigned int dest_w, dest_h;
- err = mm_util_rotate_image(src, src_width, src_height, TYPECAST_COLOR(colorspace), dest, &dest_w, &dest_h, dest_rotation);
+ err = mm_util_rotate_image(src, src_width, src_height, TYPECAST_COLOR(colorspace), dest_rotation, &res_buffer, &res_w, &res_h, &res_buffer_size);
if (err == MM_UTIL_ERROR_NONE) {
- *dest_width = (int)dest_w;
- *dest_height = (int)dest_h;
+ memcpy(dest, res_buffer, res_buffer_size);
+ *dest_width = (int)res_w;
+ *dest_height = (int)res_h;
}
return _image_error_capi(ERR_TYPE_TRANSFORM, err);
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <inttypes.h>
#include <image_util.h>
#include <image_util_type.h>
break;
}
- g_printf("imgp fmt: %d mimetype fmt: %d", colorspace, mimetype);
+ g_printf("imgp fmt[%d] mimetype fmt[%d]\n", colorspace, mimetype);
+
return mimetype;
}
return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
}
- g_printf("media_format_set_video_info success! file:%s, w:%d, h:%d, %d\n", g_path, g_width, g_height, _image_util_mapping_imgp_format_to_mime(g_format));
+ g_printf("media_format_set_video_info success! file[%s] w[%d] h[%d] mime[%d]\n", g_path, g_width, g_height, _image_util_mapping_imgp_format_to_mime(g_format));
} else {
g_printf("media_format_create failed...");
}
if (ret == MEDIA_PACKET_ERROR_NONE) {
g_printf("Success - media_packet_create_alloc\n");
uint64_t size = 0;
+ size_t readed = 0;
+
if (media_packet_get_buffer_size(g_src, &size) == MEDIA_PACKET_ERROR_NONE) {
if (media_packet_get_buffer_data_ptr(g_src, &ptr) == MEDIA_PACKET_ERROR_NONE) {
FILE *fp = fopen(g_path, "r");
fclose(fp);
return IMAGE_UTIL_ERROR_NO_SUCH_FILE;
}
- if (fread(src, 1, (size_t)size, fp) == size) {
+ readed = fread(src, 1, (size_t)size, fp);
+ if (readed <= size) {
g_printf("#Success# fread\n");
memcpy(ptr, src, (int)size);
g_printf("memcpy\n");
} else {
- g_printf("#Error# fread\n");
+ g_printf("#Error# fread readed[%zu] size[%" PRIu64 "]\n", readed, size);
}
fclose(fp);
IMAGE_UTIL_SAFE_FREE(src);
int ret = 0;
unsigned int width = 0;
unsigned int height = 0;
- image_util_colorspace_e colorspace = IMAGE_UTIL_COLORSPACE_RGB888;
+ image_util_colorspace_e colorspace = IMAGE_UTIL_COLORSPACE_ARGB8888;
int start_x;
int start_y;
int end_x;
int end_y;
if (!strcmp("convert", cmd)) {
- colorspace = IMAGE_UTIL_COLORSPACE_I420;
-
ret = image_util_transform_set_colorspace(g_handle, colorspace);
if (ret != IMAGE_UTIL_ERROR_NONE) {
- g_printf("[%d]error image_util_set colorspace [%d]\n", __LINE__, ret);
+ g_printf("[%d]error image_util_transform_set_colorspace [%d]\n", __LINE__, ret);
return;
}
}
ret = image_util_transform_set_resolution(g_handle, width, height);
if (ret != IMAGE_UTIL_ERROR_NONE) {
- g_printf("[%d]Error image_util_set resolution [%d]\n", __LINE__, ret);
+ g_printf("[%d]Error image_util_transform_set_resolution [%d]\n", __LINE__, ret);
return;
}
}
if (!strcmp("rotate", cmd)) {
ret = image_util_transform_set_rotation(g_handle, g_angle);
if (ret != IMAGE_UTIL_ERROR_NONE) {
- g_printf("[%d]Error image_util_set rotation [%d]\n", __LINE__, ret);
+ g_printf("[%d]Error image_util_transform_set_rotation [%d]\n", __LINE__, ret);
return;
}
}
ret = image_util_transform_set_crop_area(g_handle, start_x, start_y, end_x, end_y);
if (ret != IMAGE_UTIL_ERROR_NONE) {
- g_printf("[%d]Error image_util_set colorspace [%d]\n", __LINE__, ret);
+ g_printf("[%d]Error image_util_transform_set_crop_area [%d]\n", __LINE__, ret);
return;
}
}
if (!strcmp("run", cmd)) {
ret = image_util_transform_run(g_handle, g_src, (image_util_transform_completed_cb)test_transform_completed_cb, NULL);
if (ret != IMAGE_UTIL_ERROR_NONE) {
- g_printf("[%d]Error image_util_transform [%d]\n", __LINE__, ret);
+ g_printf("[%d]Error image_util_transform_run [%d]\n", __LINE__, ret);
return;
}
_wait();
g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
if (argc < 4) {
+ g_printf("Do: export XDG_RUNTIME_DIR=/run \n");
g_printf("Usage: image_utl_test filename width height format \n");
return ret;
}