Update image_util_encode_set_output_buffer to return error when image type is BMP 21/53721/4
authorVineeth TM <vineeth.tm@samsung.com>
Wed, 9 Dec 2015 02:23:30 +0000 (11:23 +0900)
committerVineeth T M <vineeth.tm@samsung.com>
Wed, 9 Dec 2015 03:00:14 +0000 (19:00 -0800)
Change-Id: I6ebe5fb21d1b3d7c60c0a0e08c1c558ed9566cee
Signed-off-by: Vineeth TM <vineeth.tm@samsung.com>
include/image_util.h
src/image_util.c

index bcdfefd..e669d0b 100755 (executable)
@@ -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
index 6ebd6d6..95f44a0 100755 (executable)
@@ -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;
                        }