IMAGE_UTIL_SAFE_FREE(image_handle);
}
-static int __image_util_create_img_handle(image_util_type_e image_type, encode_s * handle)
+int image_util_encode_create(image_util_type_e image_type, image_util_encode_h * handle)
{
int err = IMAGE_UTIL_ERROR_NONE;
mm_image_info_s *_image_handle = NULL;
mm_gif_file_h _gif_handle = NULL;
- image_util_retvm_if((handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
-
- _image_handle = (mm_image_info_s *) calloc(1, sizeof(mm_image_info_s));
- image_util_retvm_if((_image_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- handle->image_h = (void *) _image_handle;
-
- switch (image_type) {
- case IMAGE_UTIL_JPEG:
- handle->colorspace = IMAGE_UTIL_COLORSPACE_RGBA8888;
- handle->quality = 75;
- break;
- case IMAGE_UTIL_PNG:
- handle->compression = IMAGE_UTIL_PNG_COMPRESSION_6;
- break;
- case IMAGE_UTIL_GIF:
- IMAGE_UTIL_SAFE_FREE(_image_handle);
-
- err = mm_util_gif_encode_create(&_gif_handle);
- image_util_retvm_if((err != MM_UTIL_ERROR_NONE), _image_error_capi(err), "Error - mm_util_gif_encode_create is failed (%d)", err);
-
- handle->image_h = (void *) _gif_handle;
- break;
- case IMAGE_UTIL_BMP:
- break;
- default:
- image_util_error("Invalid image type [%d]", image_type);
- err = IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
- break;
- }
-
- return err;
-}
-
-int image_util_encode_create(image_util_type_e image_type, image_util_encode_h * handle)
-{
- int err = IMAGE_UTIL_ERROR_NONE;
-
image_util_fenter();
- image_util_retvm_if(handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ image_util_retvm_if(handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid handle");
+ image_util_retvm_if((image_type < IMAGE_UTIL_JPEG) || (image_type > IMAGE_UTIL_BMP), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image_type [%d]", image_type);
encode_s *_handle = (encode_s *) calloc(1, sizeof(encode_s));
image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
_handle->current_buffer_count = 0;
_handle->current_resolution_count = 0;
_handle->current_delay_count = 0;
+ _handle->colorspace = IMAGE_UTIL_COLORSPACE_RGBA8888;
+ _handle->quality = 75;
+ _handle->compression = IMAGE_UTIL_PNG_COMPRESSION_6;
- err = __image_util_create_img_handle(image_type, _handle);
- if (err != IMAGE_UTIL_ERROR_NONE) {
- image_util_error("Error - create image handle");
- IMAGE_UTIL_SAFE_FREE(_handle);
- return err;
+ if (image_type == IMAGE_UTIL_GIF) {
+ err = mm_util_gif_encode_create(&_gif_handle);
+ if (err != MM_UTIL_ERROR_NONE) {
+ IMAGE_UTIL_SAFE_FREE(_handle);
+ image_util_error("Error - mm_util_gif_encode_create is failed (%d)", err);
+ return _image_error_capi(err);
+ }
+
+ _handle->image_h = (void *) _gif_handle;
+ } else {
+ _image_handle = (mm_image_info_s *) calloc(1, sizeof(mm_image_info_s));
+ if (_image_handle == NULL) {
+ IMAGE_UTIL_SAFE_FREE(_handle);
+ image_util_error("OUT_OF_MEMORY");
+ return IMAGE_UTIL_ERROR_OUT_OF_MEMORY;
+ }
+
+ _handle->image_h = (void *) _image_handle;
}
*handle = (image_util_encode_h) _handle;