/**
*
- * @remark Creates the handle of empty color image
- *
- * @param image [in/out] The handle of the color image
- * @return This function returns created color image handle
- * if the result is 0, then handle creation succeed
- * else if the result is -1, then handle creation failed
- */
-int mm_util_create_empty_color_image(mm_util_color_image_h *image);
-
-/**
- *
* @remark Creates the handle of color image with data
*
* @param image [in/out] The handle of the color image
/**
*
- * @remark Sets the data of color image to handle
- *
- * @param image [in] The handle of the color image
- * @param width [in] The width of color image
- * @param height [in] The height of color image
- * @param color [in] The color format of color image
- * @param data [in] The data of color image
- * @param size [in] The data-size of color image
- * @return This function returns the result of setting the data in handle
- * if the result is 0, then setting the data has succeed
- * else if the result is -1, then setting the data has failed
- */
-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);
-
-/**
- *
* @remark Gets the data of color image from handle
*
* @param image [in] The handle of the color image
return TRUE;
}
-int mm_util_create_empty_color_image(mm_util_color_image_h *image)
-{
- int ret = MM_UTIL_ERROR_NONE;
- mm_image_info_s *_color_image = NULL;
-
- mm_util_retvm_if((image == NULL), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
-
- _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;
-
- return ret;
-}
-
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;
mm_image_info_s *_color_image = NULL;
mm_util_retvm_if((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");
+ mm_util_retvm_if((data == NULL || size == 0), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid data");
_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);
- if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("mm_util_set_color_image failed(%d)", ret);
+ _color_image->data = calloc(1, size);
+ if (_color_image->data == NULL) {
+ mm_util_error("Memory allocation failed");
mm_util_destroy_color_image(_color_image);
*image = NULL;
- return ret;
+ return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
- *image = (mm_util_color_image_h)_color_image;
-
- return ret;
-}
-
-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;
- 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");
- mm_util_retvm_if((data == NULL || size == 0), MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid data");
-
- _color_image->data = calloc(1, size);
- mm_util_retvm_if((_color_image->data == NULL), MM_UTIL_ERROR_OUT_OF_MEMORY, "Memory allocation failed");
-
memcpy(_color_image->data, data, size);
+
_color_image->size = size;
_color_image->width = width;
_color_image->height = height;
_color_image->color = color;
- mm_util_sec_debug("w: %lu, h: %lu, color: %u, size: %zu, data: %p", _color_image->width, _color_image->height,
- _color_image->color, _color_image->size, _color_image->data);
+ mm_util_sec_debug("w [%lu], h [%lu], color [%u], size [%zu], data [%p]", _color_image->width, _color_image->height, _color_image->color, _color_image->size, _color_image->data);
+
+ *image = (mm_util_color_image_h)_color_image;
return ret;
}