From e5c2c4b3a4f503e06e6c01ac6337be9913bfd4d8 Mon Sep 17 00:00:00 2001 From: Vineeth TM Date: Wed, 9 Dec 2015 11:23:30 +0900 Subject: [PATCH] Update image_util_encode_set_output_buffer to return error when image type is BMP Change-Id: I6ebe5fb21d1b3d7c60c0a0e08c1c558ed9566cee Signed-off-by: Vineeth TM --- include/image_util.h | 22 ++++++++++++++-------- src/image_util.c | 6 +++++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/include/image_util.h b/include/image_util.h index bcdfefd..e669d0b 100755 --- a/include/image_util.h +++ b/include/image_util.h @@ -993,8 +993,9 @@ int image_util_decode_set_jpeg_downscale(image_util_encode_h handle, image_util_ * @brief Starts decoding of the image and fills the output buffer set using image_util_decode_set_output_buffer(). * @since_tizen 3.0 * -* @remarks The output will be stored in the pointer set using image_util_decode_set_output_buffer(). -* The function executes synchronously. +* @remarks The output will be stored in the pointer set using image_util_decode_set_output_buffer().\n +* The function executes synchronously.\n +* When any of the @pre functions are not called, IMAGE_UTIL_ERROR_INVALID_PARAMETER is returned. * * @param[in] handle The handle to image util decoding * @param[out] width Width of the decoded image @@ -1027,7 +1028,8 @@ int image_util_decode_run(image_util_decode_h handle, unsigned long *width, unsi * @since_tizen 3.0 * * @remarks The output will be stored in the pointer set using image_util_decode_set_output_buffer().\n -* The function executes asynchronously, which contains complete callback. +* The function executes asynchronously, which contains complete callback.\n +* When any of the @pre functions are not called, IMAGE_UTIL_ERROR_INVALID_PARAMETER is returned. * * @param[in] handle The handle to image util decoding * @param[in] callback The callback function to be invoked @@ -1139,7 +1141,7 @@ int image_util_encode_set_resolution(image_util_encode_h handle, unsigned long w * Errors would be returned if not supported. * * @param[in] handle The handle to image util encoding -* @param[in] colorspace The decoded image colorspace +* @param[in] colorspace The encoded image colorspace * * @return @c 0 on success, * otherwise a negative error value @@ -1305,7 +1307,8 @@ int image_util_encode_set_output_path(image_util_encode_h handle, const char *pa * @since_tizen 3.0 * * @remarks One of image_util_encode_set_output_path() or image_util_encode_set_output_buffer() should be set.\n -* If both are set then the latest output set is considered. +* If both are set then the latest output set is considered.\n +* Output buffer setting is not supported for bmp. IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT will be returned for bmp. * * @param[in] handle The handle to image util encoding * @param[in] dst_buffer The output image buffer @@ -1316,6 +1319,7 @@ int image_util_encode_set_output_path(image_util_encode_h handle, const char *pa * @retval #IMAGE_UTIL_ERROR_NONE Successful * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation +* @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Invalid operation * * @pre image_util_encode_create() * @@ -1335,8 +1339,9 @@ int image_util_encode_set_output_buffer(image_util_encode_h handle, unsigned cha * @brief Starts encoding of the image and fills the output buffer, set using image_util_encode_set_output_buffer() or image_util_encode_set_output_path(). * @since_tizen 3.0 * -* @remarks The output will be stored in the pointer set to image_util_encode_set_output_buffer() or image_util_encode_set_output_path(). -* The function executes synchronously. +* @remarks The output will be stored in the pointer set to image_util_encode_set_output_buffer() or image_util_encode_set_output_path().\n +* The function executes synchronously.\n +* When any of the @pre functions are not called, IMAGE_UTIL_ERROR_INVALID_PARAMETER is returned. * * @param[in] handle The handle to image util encoding * @param[out] size Size of the encoded image @@ -1369,7 +1374,8 @@ int image_util_encode_run(image_util_encode_h handle, unsigned long long *size); * @since_tizen 3.0 * * @remarks The output will be stored in the pointer set to image_util_encode_set_output_buffer() or image_util_encode_set_output_path().\n -* The function executes asynchronously, which contains complete callback. +* The function executes asynchronously, which contains complete callback.\n +* When any of the @pre functions are not called, IMAGE_UTIL_ERROR_INVALID_PARAMETER is returned. * * @param[in] handle The handle to image util encoding * @param[in] callback The callback function to be invoked diff --git a/src/image_util.c b/src/image_util.c index 6ebd6d6..95f44a0 100755 --- a/src/image_util.c +++ b/src/image_util.c @@ -1807,6 +1807,10 @@ int image_util_encode_set_output_buffer(image_util_encode_h handle, unsigned cha image_util_error("Invalid Handle"); return IMAGE_UTIL_ERROR_INVALID_PARAMETER; } + if (_handle->image_type == IMAGE_UTIL_BMP) { + image_util_error("BMP library does not support encoding to memory"); + return IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT; + } if (dst_buffer == NULL) { image_util_error("Invalid output buffer"); return IMAGE_UTIL_ERROR_INVALID_PARAMETER; @@ -1897,7 +1901,7 @@ static int _image_util_encode_internal(decode_encode_s * _handle) if (_handle->path) err = mm_util_encode_bmp_to_file(bmp_data, _handle->path); else { - fprintf(stderr, "\tNot yet implemented\n"); + image_util_error("Not yet implemented"); return MM_UTIL_ERROR_INVALID_PARAMETER; } -- 2.7.4