#endif
#include "mm_util_type.h"
-/**
- @addtogroup UTILITY
- @{
-
- @par
- This part describes the APIs with repect to multimedia image library.
-*/
-
-typedef struct {
- unsigned long width; /**< width */
- unsigned long height; /**< height */
- size_t size; /**< size */
- void *data; /**< data */
-} mm_util_bmp_data;
-
-/**
- * This function decodes bmp image(file) to color image(raw data)
- *
- * @param filename [in] the input file, encoded bmp image
- * @param decoded [out] the pointer of mm_util_bmp_data.
- * After using it, please free the allocated memory.
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_bmp_data
- * @since R1, 1.0
- */
-int mm_util_decode_from_bmp_file(const char *filename, mm_util_bmp_data * decoded);
-
-/**
- * This function decodes bmp image(memory) to color image(raw data)
- *
- * @param memory [in] the input memory, encoded bmp image
- * @param src_size [in] the size of input memory
- * @param decoded [out] the pointer of mm_util_bmp_data.
- * After using it, please free the allocated memory.
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_bmp_data
- * @since R1, 1.0
- */
-int mm_util_decode_from_bmp_memory(void *memory, const size_t src_size, mm_util_bmp_data * decoded);
-
-/**
- * This function encodes color image(raw data) to bmp file
- *
- * @param decoded [in] the pointer of mm_util_bmp_data.
- * After using it, please free the allocated memory.
- * @param filename [out] the output file name on to which the encoded bmp stream will be written.
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_bmp_data
- * @since R1, 1.0
- */
-int mm_util_encode_bmp_to_file(mm_util_bmp_data * decoded, const char *filename);
-
-/**
- * This function encodes color image(raw data) to buffer
- *
- * @param decoded [in] the pointer of mm_util_bmp_data.
- * After using it, please free the allocated memory.
- * @param buffer [out] the output memory on to which the encoded bmp stream will be written.
- * @param size [out] The size of output buffer on to which the encoded stream will be written.
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_bmp_data
- * @since R1, 1.0
- */
-int mm_util_encode_bmp_to_memory(mm_util_bmp_data *decoded, void **buffer, size_t *size);
+int mm_util_decode_from_bmp_file(const char *filename, mm_image_info_s * decoded);
+int mm_util_decode_from_bmp_memory(void *memory, const size_t src_size, mm_image_info_s * decoded);
+int mm_util_encode_bmp_to_file(mm_image_info_s * decoded, const char *filename);
+int mm_util_encode_bmp_to_memory(mm_image_info_s *decoded, void **buffer, size_t *size);
#ifdef __cplusplus
}
}
/* decodes bmp image to color image */
-static int _read_bmp(const char *filename, void *memory, size_t src_size, mm_util_bmp_data *decoded)
+static int _read_bmp(const char *filename, void *memory, size_t src_size, mm_image_info_s *decoded)
{
bmp_bitmap_callback_vt bitmap_callbacks = {
__bitmap_create,
}
/* encodes color image to bmp image */
-static int _write_bmp(mm_util_bmp_data *decoded, const char *filename, void **memory, size_t *src_size)
+static int _write_bmp(mm_image_info_s *decoded, const char *filename, void **memory, size_t *src_size)
{
bmpfile_t *bmp;
rgb_pixel_t pixel = { 0, 0, 0, 0 };
return MM_UTIL_ERROR_NONE;
}
-int mm_util_decode_from_bmp_file(const char *filename, mm_util_bmp_data *decoded)
+int mm_util_decode_from_bmp_file(const char *filename, mm_image_info_s *decoded)
{
int ret = MM_UTIL_ERROR_NONE;
return ret;
}
-int mm_util_decode_from_bmp_memory(void *memory, const size_t src_size, mm_util_bmp_data *decoded)
+int mm_util_decode_from_bmp_memory(void *memory, const size_t src_size, mm_image_info_s *decoded)
{
int ret = MM_UTIL_ERROR_NONE;
return ret;
}
-int mm_util_encode_bmp_to_file(mm_util_bmp_data *decoded, const char *filename)
+int mm_util_encode_bmp_to_file(mm_image_info_s *decoded, const char *filename)
{
int ret = MM_UTIL_ERROR_NONE;
return ret;
}
-int mm_util_encode_bmp_to_memory(mm_util_bmp_data *decoded, void **buffer, size_t *size)
+int mm_util_encode_bmp_to_memory(mm_image_info_s *decoded, void **buffer, size_t *size)
{
int ret = MM_UTIL_ERROR_NONE;
static void *g_readed_data = NULL;
static size_t g_readed_size = 0;
-static mm_util_bmp_data g_decoded_data = {0,};
+static mm_image_info_s g_decoded_data = {0,};
static gboolean _read_file(char *path, void **data, size_t *length)
{
#define MM_UTIL_ROUND_DOWN_4(num) ((num)&(~3))
#define MM_UTIL_ROUND_DOWN_16(num) ((num)&(~15))
-typedef struct {
- unsigned long width;
- unsigned long height;
- mm_util_color_format_e color;
- void *data;
- size_t size;
-} color_image_data_s;
-
int mm_util_safe_fopen(const char *path, const char *mode, FILE **fp);
void mm_util_safe_fclose(FILE *fp);
typedef void *mm_util_color_image_h;
+typedef struct {
+ unsigned long width;
+ unsigned long height;
+ mm_util_color_format_e color;
+ void *data;
+ size_t size;
+} mm_image_info_s;
+
#ifdef __cplusplus
}
#endif
int mm_util_create_empty_color_image(mm_util_color_image_h *image)
{
int ret = MM_UTIL_ERROR_NONE;
- color_image_data_s *_color_image = NULL;
+ mm_image_info_s *_color_image = NULL;
mm_util_retvm_if((image == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
- _color_image = (color_image_data_s *)calloc(1, sizeof(color_image_data_s));
+ _color_image = (mm_image_info_s *)calloc(1, sizeof(mm_image_info_s));
mm_util_retvm_if((_color_image == NULL), MM_UTIL_ERROR_OUT_OF_MEMORY, "Memory allocation failed");
*image = (mm_util_color_image_h)_color_image;
int mm_util_create_color_image(mm_util_color_image_h *image, unsigned long width, unsigned long height, mm_util_color_format_e color, void *data, size_t size)
{
int ret = MM_UTIL_ERROR_NONE;
- color_image_data_s *_color_image = NULL;
+ mm_image_info_s *_color_image = NULL;
mm_util_retvm_if((image == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
- _color_image = (color_image_data_s *)calloc(1, sizeof(color_image_data_s));
+ _color_image = (mm_image_info_s *)calloc(1, sizeof(mm_image_info_s));
mm_util_retvm_if((_color_image == NULL), MM_UTIL_ERROR_OUT_OF_MEMORY, "Memory allocation failed");
ret = mm_util_set_color_image(_color_image, width, height, color, data, size);
int mm_util_set_color_image(mm_util_color_image_h image, unsigned long width, unsigned long height, mm_util_color_format_e color, void *data, size_t size)
{
int ret = MM_UTIL_ERROR_NONE;
- color_image_data_s *_color_image = (color_image_data_s *)image;
+ mm_image_info_s *_color_image = (mm_image_info_s *)image;
mm_util_retvm_if((_color_image == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
mm_util_retvm_if((color >= MM_UTIL_COLOR_NUM), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid color");
int mm_util_get_color_image(mm_util_color_image_h image, unsigned long *width, unsigned long *height, mm_util_color_format_e *color, void **data, size_t *size)
{
int ret = MM_UTIL_ERROR_NONE;
- color_image_data_s *_color_image = (color_image_data_s *)image;
+ mm_image_info_s *_color_image = (mm_image_info_s *)image;
mm_util_retvm_if((_color_image == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
void mm_util_destroy_color_image(mm_util_color_image_h image)
{
- color_image_data_s *_color_image = (color_image_data_s *)image;
+ mm_image_info_s *_color_image = (mm_image_info_s *)image;
if (_color_image == NULL) {
mm_util_error("[ERROR] - image");
}
/* decode jpg image */
- mm_util_jpeg_yuv_data decoded;
- memset(&decoded, 0, sizeof(mm_util_jpeg_yuv_data));
+ mm_image_info_s decoded;
+ memset(&decoded, 0, sizeof(mm_image_info_s));
ret = mm_util_decode_from_jpeg_file(argv[1], MM_UTIL_COLOR_RGB24, MM_UTIL_JPEG_DECODE_DOWNSCALE_1_1, &decoded);
} mm_util_cb_s;
typedef struct {
- color_image_data_s *src;
- color_image_data_s *dst;
+ mm_image_info_s *src;
+ mm_image_info_s *dst;
/* for converting colorspace */
mm_util_color_format_e dst_format;
#define GST "gstcs"
typedef gboolean(*IMGPInfoFunc) (imgp_info_s *, const unsigned char *, unsigned char **, imgp_plugin_type_e);
-static int __mm_util_transform_exec(mm_util_s *handle, color_image_data_s *source_image);
+static int __mm_util_transform_exec(mm_util_s *handle, mm_image_info_s *source_image);
static int check_valid_picture_size(int width, int height)
{
continue;
}
- ret = __mm_util_transform_exec(handle, (color_image_data_s *)pop_data); /* Need to block */
+ ret = __mm_util_transform_exec(handle, (mm_image_info_s *)pop_data); /* Need to block */
if (ret == MM_UTIL_ERROR_NONE)
mm_util_debug("Success - transform_exec");
else
return ret;
}
-static int __mm_util_transform_exec(mm_util_s *handle, color_image_data_s *source_image)
+static int __mm_util_transform_exec(mm_util_s *handle, mm_image_info_s *source_image)
{
int ret = MM_UTIL_ERROR_NONE;
MM_UTIL_JPEG_DECODE_DOWNSCALE_1_8 = 8, /** 1/8 downscale decode */
} mm_util_jpeg_decode_downscale;
-/**
- * YUV data
- */
-typedef struct {
- mm_util_color_format_e format; /**< pixel format*/
- int width; /**< width */
- int height; /**< heigt */
- size_t size; /**< size */
- void *data; /**< data */ // int decode_yuv_subsample; /**< decode_yuv_subsample */
-} mm_util_jpeg_yuv_data;
-
-
-/**
- * This function encodes rawfile to jpeg file.
- *
- * @param decoded [in] pointer of input stream pointer, that is, pointer of decoded data.
- * @param quality [in] encoding quality, from 1 to 100
- * @param filename [in] output file name
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_color_format_e
- * @since R1, 1.0
- */
-int mm_util_jpeg_encode_to_file(mm_util_jpeg_yuv_data *decoded, int quality, const char *filename);
-
-
-/**
- * This function encodes raw file to jpeg into memory.
- *
- * @param decoded [in] pointer of input stream pointer, that is, pointer of decoded data.
- * @param quality [in] encoding quality, from 1 to 100
- * @param mem [out] pointer of output stream pointer, that is, pointer of encoded jpeg stream pointer. After using it, please free the allocated memory.
- * @param size [out] output stream size, that is, encoded stream size
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_color_format_e
- * @since R1, 1.0
- */
+int mm_util_jpeg_encode_to_file(mm_image_info_s *decoded, int quality, const char *filename);
int mm_util_jpeg_encode_to_memory(void **mem, unsigned int *size, unsigned char *src, unsigned int width, unsigned int height, mm_util_color_format_e color, int quality);
-
-/**
- * This function encodes raw file to jpeg into memory.
- *
- * @param decoded [in] pointer of input stream pointer, that is, pointer of decoded data.
- * @param quality [in] encoding quality, from 1 to 100
- * @param mem [out] pointer of output stream pointer, that is, pointer of encoded jpeg stream pointer. After using it, please free the allocated memory.
- * @param size [out] output stream size, that is, encoded stream size
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_color_format_e
- * @since R1, 1.0
- */
-int mm_util_encode_to_jpeg_memory(mm_util_jpeg_yuv_data *decoded, int quality, void **mem, size_t *size);
-
-/**
- * This function extracts yuv data from jpeg file with downscale decode option
- *
- * @param filename [in] input file name, encoded stream file
- * @param fmt [in] color format
- * @param downscale [in] downscale value
- * @param decoded [out] pointer of output stream pointer, that is, pointer of encoded jpeg stream pointer. After using it, please free the allocated memory.
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_jpeg_yuv_data, mm_util_color_format_e
- * @since R1, 1.0
- */
-int mm_util_decode_from_jpeg_file(const char *filename, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_util_jpeg_yuv_data *decoded);
-
-/**
- * This function extracts yuv data from jpeg buffer with downscale decode option
- *
- * @param src [in] input stream pointer(pointer of encoded jpeg stream data)
- * @param size [in] size of input stream(size of pointer of encoded jpeg stream data)
- * @param fmt [in] color format
- * @param downscale [in] downscale value
- * @param decoded [out] pointer of output stream pointer, that is, pointer of encoded jpeg stream pointer. After using it, please free the allocated memory.
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_jpeg_yuv_data, mm_util_color_format_e
- * @since R1, 1.0
- */
-int mm_util_decode_from_jpeg_memory(void *src, const size_t size, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_util_jpeg_yuv_data *decoded);
+int mm_util_encode_to_jpeg_memory(mm_image_info_s *decoded, int quality, void **mem, size_t *size);
+int mm_util_decode_from_jpeg_file(const char *filename, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_image_info_s *decoded);
+int mm_util_decode_from_jpeg_memory(void *src, const size_t size, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_image_info_s *decoded);
#ifdef __cplusplus
return iErrorCode;
}
-static int __mm_image_decode_with_libjpeg(mm_util_jpeg_cont_format_e control_format, FILE *fp, void *src, size_t size, mm_util_color_format_e color_format, mm_util_jpeg_decode_downscale downscale, mm_util_jpeg_yuv_data *decoded_data)
+static int __mm_image_decode_with_libjpeg(mm_util_jpeg_cont_format_e control_format, FILE *fp, void *src, size_t size, mm_util_color_format_e color_format, mm_util_jpeg_decode_downscale downscale, mm_image_info_s *decoded_data)
{
int iErrorCode = MM_UTIL_ERROR_NONE;
struct jpeg_decompress_struct dinfo;
dinfo.out_color_space = JCS_EXT_ARGB;
mm_util_debug("cinfo.out_color_space = JCS_EXT_ARGB");
}
- decoded_data->format = color_format;
+ decoded_data->color = color_format;
/* Start decompressor */
jpeg_start_decompress(&dinfo);
}
decoded_data->data = (void *) calloc(1, decoded_data->size);
- decoded_data->format = color_format;
+ decoded_data->color = color_format;
if (decoded_data->data == NULL) {
jpeg_finish_decompress(&dinfo);
return iErrorCode;
}
-int mm_util_jpeg_encode_to_file(mm_util_jpeg_yuv_data *decoded, int quality, const char *filename)
+int mm_util_jpeg_encode_to_file(mm_image_info_s *decoded, int quality, const char *filename)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_retvm_if(decoded == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src");
mm_util_retvm_if(decoded->data == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src data");
mm_util_retvm_if((decoded->width <= 0) || (decoded->height <= 0), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid width[%d] height[%d]", decoded->width, decoded->height);
- mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(decoded->format) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", decoded->format);
- mm_util_retvm_if((!_mm_util_is_supported_color_format(decoded->format)), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported fmt [%d]", decoded->format);
+ mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(decoded->color) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", decoded->color);
+ mm_util_retvm_if((!_mm_util_is_supported_color_format(decoded->color)), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported fmt [%d]", decoded->color);
mm_util_retvm_if((quality < 1) || (quality > 100), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid quality [%d]", quality);
mm_util_debug("#START# LIBJPEG");
return ret;
}
- if (decoded->format == MM_UTIL_COLOR_NV12) {
+ if (decoded->color == MM_UTIL_COLOR_NV12) {
unsigned int res_w = 0;
unsigned int res_h = 0;
size_t res_buffer_size = 0;
MMUTIL_SAFE_FREE(dst);
} else {
- ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_FILE, decoded->data, decoded->width, decoded->height, decoded->format, quality, fp, NULL, NULL);
+ ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_FILE, decoded->data, decoded->width, decoded->height, decoded->color, quality, fp, NULL, NULL);
}
fsync((int)(fp->_fileno));
int ret = MM_UTIL_ERROR_NONE;
size_t encoded_size = 0;
- mm_util_jpeg_yuv_data decoded;
- memset(&decoded, 0, sizeof(mm_util_jpeg_yuv_data));
+ mm_image_info_s decoded;
+ memset(&decoded, 0, sizeof(mm_image_info_s));
decoded.width = (int)width;
decoded.height = (int)height;
- decoded.format = color;
+ decoded.color = color;
decoded.data = src;
ret = mm_util_encode_to_jpeg_memory(&decoded, quality, mem, &encoded_size);
return ret;
}
-int mm_util_encode_to_jpeg_memory(mm_util_jpeg_yuv_data *decoded, int quality, void **mem, size_t *size)
+int mm_util_encode_to_jpeg_memory(mm_image_info_s *decoded, int quality, void **mem, size_t *size)
{
int ret = MM_UTIL_ERROR_NONE;
mm_util_retvm_if(decoded == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src");
mm_util_retvm_if(decoded->data == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid src data");
mm_util_retvm_if((decoded->width <= 0) || (decoded->height <= 0), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid width[%d] height[%d]", decoded->width, decoded->height);
- mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(decoded->format) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", decoded->format);
- mm_util_retvm_if((!_mm_util_is_supported_color_format(decoded->format)), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported fmt [%d]", decoded->format);
+ mm_util_retvm_if((IS_MM_UTIL_COLOR_FORMAT(decoded->color) == FALSE), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid fmt [%d]", decoded->color);
+ mm_util_retvm_if((!_mm_util_is_supported_color_format(decoded->color)), MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "not supported fmt [%d]", decoded->color);
mm_util_retvm_if((quality < 1) || (quality > 100), MM_UTIL_ERROR_INVALID_PARAMETER, "invalid quality [%d]", quality);
mm_util_debug("#START# libjpeg");
- if (decoded->format == MM_UTIL_COLOR_NV12) {
+ if (decoded->color == MM_UTIL_COLOR_NV12) {
unsigned int res_w = 0;
unsigned int res_h = 0;
size_t res_buffer_size = 0;
MMUTIL_SAFE_FREE(dst);
} else {
- ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_MEM, decoded->data, decoded->width, decoded->height, decoded->format, quality, NULL, mem, size);
+ ret = __mm_image_encode_with_libjpeg(MM_UTIL_JPEG_MEM, decoded->data, decoded->width, decoded->height, decoded->color, quality, NULL, mem, size);
}
mm_util_debug("#END# libjpeg, Success!! ret: %d", ret);
return ret;
}
-int mm_util_decode_from_jpeg_file(const char *filename, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_util_jpeg_yuv_data *decoded)
+int mm_util_decode_from_jpeg_file(const char *filename, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_image_info_s *decoded)
{
int ret = MM_UTIL_ERROR_NONE;
return ret;
}
-int mm_util_decode_from_jpeg_memory(void *src, const size_t size, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_util_jpeg_yuv_data *decoded)
+int mm_util_decode_from_jpeg_memory(void *src, const size_t size, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_image_info_s *decoded)
{
int ret = MM_UTIL_ERROR_NONE;
static void *g_readed_data = NULL;
static size_t g_readed_size = 0;
-static mm_util_jpeg_yuv_data g_decoded_data = {0,};
+static mm_image_info_s g_decoded_data = {0,};
static gboolean _read_file(char *path, void **data, size_t *length)
{
_print_help(argv[0]);
return FALSE;
}
- if (FALSE == _get_input_data(argv[3], 0, INT_MAX, &g_decoded_data.width)) {
+ if (FALSE == _get_input_data(argv[3], 0, INT_MAX, (int *)&g_decoded_data.width)) {
fprintf(stderr, "\t[JPEG_testsuite] wrong width %s\n", argv[3]);
return FALSE;
}
- if (FALSE == _get_input_data(argv[4], 0, INT_MAX, &g_decoded_data.height)) {
+ if (FALSE == _get_input_data(argv[4], 0, INT_MAX, (int *)&g_decoded_data.height)) {
fprintf(stderr, "\t[JPEG_testsuite] wrong height %s\n", argv[4]);
return FALSE;
}
fprintf(stderr, "\t[JPEG_testsuite] reading file error\n");
return FALSE;
}
- g_decoded_data.format = (mm_util_color_format_e)g_color;
+ g_decoded_data.color = (mm_util_color_format_e)g_color;
/* test encoding jpeg */
if (mode == TEST_ENCODE_FILE) {
#include "mm_util_private.h"
#include "mm_util_magick.h"
-typedef struct _util_image_s {
- unsigned char *buffer;
- unsigned int width;
- unsigned int height;
- size_t size;
- mm_util_color_format_e format;
-} util_image_s;
-
static bool __mm_util_check_angle(mm_util_magick_rotate_type angle);
static void __mm_util_magick_log_method(const ExceptionType excep, const char *message)
static Image * __mm_util_constitute_image(mm_util_image_h handle, const char *map)
{
- util_image_s *_handle = (util_image_s*)handle;
+ mm_image_info_s *_handle = (mm_image_info_s*)handle;
Image *_image = NULL;
ExceptionInfo exception;
GetExceptionInfo(&exception);
/* Read image from buffer */
- _image = ConstituteImage(_handle->width, _handle->height, map, CharPixel, _handle->buffer, &exception);
+ _image = ConstituteImage(_handle->width, _handle->height, map, CharPixel, _handle->data, &exception);
if (_image == NULL) {
mm_util_error("Error: Getting Image failed.");
if (exception.severity != UndefinedException)
mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
- util_image_s *_handle = (util_image_s*)calloc(1, sizeof(util_image_s));
+ mm_image_info_s *_handle = (mm_image_info_s*)calloc(1, sizeof(mm_image_info_s));
mm_util_retvm_if(_handle == NULL, MM_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- _handle->buffer = (unsigned char *)buffer;
+ _handle->data = (unsigned char *)buffer;
_handle->width = width;
_handle->height = height;
_handle->size = size;
- _handle->format = format;
+ _handle->color = format;
*handle = (mm_util_image_h)_handle;
mm_util_retvm_if(size == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid size");
mm_util_retvm_if(format == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid format");
- util_image_s *_handle = (util_image_s*)handle;
+ mm_image_info_s *_handle = (mm_image_info_s*)handle;
- *buffer = _handle->buffer;
+ *buffer = _handle->data;
*width = _handle->width;
*height = _handle->height;
*size = _handle->size;
- *format = _handle->format;
+ *format = _handle->color;
return ret;
}
{
mm_util_retvm_if(handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
- util_image_s *_handle = (util_image_s*)handle;
+ mm_image_info_s *_handle = (mm_image_info_s*)handle;
MMUTIL_SAFE_FREE(_handle);
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 ret = MM_UTIL_ERROR_NONE;
- util_image_s *_src_handle = (util_image_s*)src_handle;
+ mm_image_info_s *_src_handle = (mm_image_info_s*)src_handle;
char *map = NULL;
Image *_image = NULL;
Image *_processed_image = NULL;
mm_util_debug("angle [%d]", angle);
- ret = __mm_util_get_map(_src_handle->format, &map);
+ ret = __mm_util_get_map(_src_handle->color, &map);
mm_util_retvm_if((ret != MM_UTIL_ERROR_NONE) || (map == NULL), ret, "fail to get map");
__mm_util_init(&exception);
goto ERROR;
}
- ret = mm_util_create_handle(dst_handle, pixels, _processed_image->columns, _processed_image->rows, pixels_size, _src_handle->format);
+ ret = mm_util_create_handle(dst_handle, pixels, _processed_image->columns, _processed_image->rows, pixels_size, _src_handle->color);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("Error: __mm_util_write_image_to_buffer failed.");
MagickFree(pixels);
int mm_util_rotate_B_P(mm_util_image_h src_handle, mm_util_magick_rotate_type angle, const char *dst_path)
{
int ret = MM_UTIL_ERROR_NONE;
- util_image_s *_src_handle = (util_image_s*)src_handle;
+ mm_image_info_s *_src_handle = (mm_image_info_s*)src_handle;
char *map = NULL;
Image *_image = NULL;
Image *_processed_image = NULL;
mm_util_sec_debug("angle [%d] dst_path [%s]", angle, dst_path);
- ret = __mm_util_get_map(_src_handle->format, &map);
+ ret = __mm_util_get_map(_src_handle->color, &map);
mm_util_retvm_if((ret != MM_UTIL_ERROR_NONE) || (map == NULL), ret, "fail to get map");
__mm_util_init(&exception);
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 ret = MM_UTIL_ERROR_NONE;
- util_image_s *_src_handle = (util_image_s*)src_handle;
+ mm_image_info_s *_src_handle = (mm_image_info_s*)src_handle;
char *map = NULL;
Image *_image = NULL;
Image *_processed_image = NULL;
mm_util_debug("req_width [%u] req_height [%u]", req_width, req_height);
- ret = __mm_util_get_map(_src_handle->format, &map);
+ ret = __mm_util_get_map(_src_handle->color, &map);
mm_util_retvm_if((ret != MM_UTIL_ERROR_NONE) || (map == NULL), ret, "fail to get map");
__mm_util_init(&exception);
goto ERROR;
}
- ret = mm_util_create_handle(dst_handle, pixels, _processed_image->columns, _processed_image->rows, pixels_size, _src_handle->format);
+ ret = mm_util_create_handle(dst_handle, pixels, _processed_image->columns, _processed_image->rows, pixels_size, _src_handle->color);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("Error: __mm_util_write_image_to_buffer failed.");
MagickFree(pixels);
int mm_util_resize_B_P(mm_util_image_h src_handle, unsigned int req_width, unsigned int req_height, const char *dst_path)
{
int ret = MM_UTIL_ERROR_NONE;
- util_image_s *_src_handle = (util_image_s*)src_handle;
+ mm_image_info_s *_src_handle = (mm_image_info_s*)src_handle;
char *map = NULL;
Image *_image = NULL;
Image *_processed_image = NULL;
mm_util_sec_debug("req_width [%u] req_height [%u] dst_path [%s]", req_width, req_height, dst_path);
- ret = __mm_util_get_map(_src_handle->format, &map);
+ ret = __mm_util_get_map(_src_handle->color, &map);
mm_util_retvm_if((ret != MM_UTIL_ERROR_NONE) || (map == NULL), ret, "fail to get map");
__mm_util_init(&exception);
int mm_util_convert_B_B(mm_util_image_h src_handle, mm_util_color_format_e req_format, mm_util_image_h *dst_handle)
{
int ret = MM_UTIL_ERROR_NONE;
- util_image_s *_src_handle = (util_image_s*)src_handle;
+ mm_image_info_s *_src_handle = (mm_image_info_s*)src_handle;
char *map = NULL;
Image *_image = NULL;
ExceptionInfo exception;
mm_util_retvm_if(src_handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid handle");
mm_util_retvm_if(dst_handle == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid dst_handle");
- mm_util_debug("input format [%d] req_format [%d]", _src_handle->format, req_format);
+ mm_util_debug("input format [%d] req_format [%d]", _src_handle->color, req_format);
- ret = __mm_util_get_map(_src_handle->format, &map);
+ ret = __mm_util_get_map(_src_handle->color, &map);
mm_util_retvm_if((ret != MM_UTIL_ERROR_NONE) || (map == NULL), ret, "fail to get map");
__mm_util_init(&exception);
goto ERROR;
}
- ret = mm_util_create_handle(dst_handle, pixels, _image->columns, _image->rows, pixels_size, _src_handle->format);
+ ret = mm_util_create_handle(dst_handle, pixels, _image->columns, _image->rows, pixels_size, _src_handle->color);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("Error: __mm_util_write_image_to_buffer failed.");
MagickFree(pixels);
MM_UTIL_COMPRESSION_9 = 9 /* Best compression */
} mm_util_png_compression;
-typedef struct {
- unsigned long width; /**< Width*/
- unsigned long height; /**< Height*/
- size_t size; /**< size */
- void *data; /**< data */
-} mm_util_png_data;
-
-/**
- * This function extracts raw data from png file
- *
- * @param fpath [in] input file name, encoded stream file
- * @param decoded [out] pointer of mm_util_png_data.
- * After using it, please free the allocated memory.
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_png_data, mm_util_init_decode_png
- * @since R1, 1.0
- */
-int mm_util_decode_from_png_file(const char *fpath, mm_util_png_data * decoded);
-
-/**
- * This function extracts raw data from png buffer
- *
- * @param memory [in] input stream pointer(pointer of encoded png stream data)
- * @param src_size [in] size of input stream(size of pointer of encoded png stream data)
- * @param decoded [out] pointer of mm_util_png_data.
- * After using it, please free the allocated memory.
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_png_data, mm_util_init_decode_png
- * @since R1, 1.0
- */
-int mm_util_decode_from_png_memory(void *memory, const size_t src_size, mm_util_png_data * decoded);
-
-/**
- * This function extracts raw data to png file
- *
- * @param decoded [in] information of the raw data.
- * @param compression_level [in] compression level
- * @param fpath [out] output file name on to which the encoded stream will be written.
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_png_data, mm_util_init_encode_png
- * @since R1, 1.0
- */
-int mm_util_encode_to_png_file(mm_util_png_data *decoded, mm_util_png_compression compression_level, const char *fpath);
-
-/**
- * This function extracts raw data to memory
- *
- * @param decoded [in] information of the raw data.
- * @param compression_level [in] compression level
- * @param data [out] pointer of encoded data.
- * @param size [out] size of encoded data.
- * After using it, please free the allocated memory.
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_png_data, mm_util_init_encode_png
- * @since R1, 1.0
- */
-int mm_util_encode_to_png_memory(mm_util_png_data *decoded, mm_util_png_compression compression_level, void **data, size_t *size);
+int mm_util_decode_from_png_file(const char *fpath, mm_image_info_s * decoded);
+int mm_util_decode_from_png_memory(void *memory, const size_t src_size, mm_image_info_s * decoded);
+int mm_util_encode_to_png_file(mm_image_info_s *decoded, mm_util_png_compression compression_level, const char *fpath);
+int mm_util_encode_to_png_memory(mm_image_info_s *decoded, mm_util_png_compression compression_level, void **data, size_t *size);
#ifdef __cplusplus
}
}
-static int _read_png(FILE *fp, void *memory, const size_t memory_size, mm_util_png_data *decoded)
+static int _read_png(FILE *fp, void *memory, const size_t memory_size, mm_image_info_s *decoded)
{
png_structp png_ptr;
png_infop info_ptr;
return MM_UTIL_ERROR_NONE;
}
-int _write_png(mm_util_png_data *decoded, mm_util_png_compression compression_level, FILE *fp, void **buffer, size_t *size)
+int _write_png(mm_image_info_s *decoded, mm_util_png_compression compression_level, FILE *fp, void **buffer, size_t *size)
{
png_structp png_ptr;
png_infop info_ptr;
return MM_UTIL_ERROR_NONE;
}
-int mm_util_decode_from_png_file(const char *fpath, mm_util_png_data *decoded)
+int mm_util_decode_from_png_file(const char *fpath, mm_image_info_s *decoded)
{
int ret = MM_UTIL_ERROR_NONE;
FILE *fp = NULL;
return ret;
}
-int mm_util_decode_from_png_memory(void *memory, const size_t src_size, mm_util_png_data *decoded)
+int mm_util_decode_from_png_memory(void *memory, const size_t src_size, mm_image_info_s *decoded)
{
int ret = MM_UTIL_ERROR_NONE;
return ret;
}
-int mm_util_encode_to_png_file(mm_util_png_data *decoded, mm_util_png_compression compression_level, const char *fpath)
+int mm_util_encode_to_png_file(mm_image_info_s *decoded, mm_util_png_compression compression_level, const char *fpath)
{
int ret = MM_UTIL_ERROR_NONE;
FILE *fp = NULL;
return ret;
}
-int mm_util_encode_to_png_memory(mm_util_png_data *decoded, mm_util_png_compression compression_level, void **data, size_t *size)
+int mm_util_encode_to_png_memory(mm_image_info_s *decoded, mm_util_png_compression compression_level, void **data, size_t *size)
{
int ret = MM_UTIL_ERROR_NONE;
static void *g_readed_data = NULL;
static size_t g_readed_size = 0;
-static mm_util_png_data g_decoded_data = {0,};
+static mm_image_info_s g_decoded_data = {0,};
static gboolean _read_file(char *path, void **data, size_t *length)
{