Add to support saving bmp to memory 74/133574/7
authorJiyong Min <jiyong.min@samsung.com>
Mon, 12 Jun 2017 06:38:38 +0000 (15:38 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Tue, 13 Jun 2017 23:03:02 +0000 (08:03 +0900)
Change-Id: Ie085a56aeb434d037b66d934ca8d19e6d81c9140
Signed-off-by: jiyong min <jiyong.min@samsung.com>
decode-test/image_util_decode_encode_testsuite.c
packaging/capi-media-image-util.spec
src/image_util.c

index d495481..657b86a 100755 (executable)
@@ -28,7 +28,7 @@
 #include <image_util.h>
 #include <glib.h>
 
-#define DECODE_RESULT_PATH "/media/decode_test."
+#define DECODE_RESULT_PATH "/home/owner/media/decode_test."
 #define BUFFER_SIZE 128
 
 unsigned long image_width = 0, image_height = 0;
@@ -196,7 +196,7 @@ int main(int argc, char *argv[])
                }
 
                while ((dp = readdir(fd)) != NULL) {
-                       if (dp->d_name == NULL)
+                       if (strlen(dp->d_name) == 0)
                                continue;
                        if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
                                continue;               /* skip self and parent */
@@ -206,8 +206,7 @@ int main(int argc, char *argv[])
 
                                if (temp1 == NULL || temp2 == NULL) {
                                        fprintf(stderr, "\t\tCannot find test format\n");
-                                       closedir(fd);
-                                       return 0;
+                                       continue;
                                }
 
                                strncpy(temp_filename, dp->d_name, strlen(dp->d_name) - strlen(temp1));
@@ -416,10 +415,7 @@ int main(int argc, char *argv[])
                        return 0;
 
                if (!strcmp("decode-mem", argv[1])) {
-                       if (encode_image_type == IMAGE_UTIL_BMP)
-                               ret = image_util_encode_set_output_path(encoded, filename);
-                       else
-                               ret = image_util_encode_set_output_buffer(encoded, &dst);
+                       ret = image_util_encode_set_output_buffer(encoded, &dst);
                        if (ret != IMAGE_UTIL_ERROR_NONE)
                                return 0;
                } else {
@@ -440,7 +436,7 @@ int main(int argc, char *argv[])
                if (ret != IMAGE_UTIL_ERROR_NONE)
                        return 0;
 
-               if (!strcmp("decode-mem", argv[1]) && (encode_image_type != IMAGE_UTIL_BMP)) {
+               if (!strcmp("decode-mem", argv[1])) {
                        _write_file(filename, (void *)dst, image_size);
                        free(dst);
                }
index 4fd6fc0..b7a9b15 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-image-util
 Summary:    A Image Utility library in Tizen Native API
-Version:    0.1.16
+Version:    0.1.17
 Release:    2
 Group:      Multimedia/API
 License:    Apache-2.0
index 5579675..914d824 100755 (executable)
@@ -1520,9 +1520,8 @@ static void _image_util_encode_destroy_image_handle(decode_encode_s * handle)
        void *image_handle = (void *)(handle->image_h);
        image_util_retm_if((image_handle == NULL), "Invalid image handle");
 
-       if (handle->image_type == IMAGE_UTIL_GIF)
-       {
-               mm_util_encode_close_gif( (mm_util_gif_data *) image_handle);
+       if (handle->image_type == IMAGE_UTIL_GIF) {
+               mm_util_encode_close_gif((mm_util_gif_data *) image_handle);
                _image_util_encode_destroy_gif_buffer(image_handle);
        }
        IMAGE_UTIL_SAFE_FREE(image_handle);
@@ -1991,10 +1990,6 @@ 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;
@@ -2090,13 +2085,16 @@ static int _image_util_encode_internal(decode_encode_s * _handle)
                        }
 
                        bmp_data->data = _handle->src_buffer[0];
-                       if (_handle->path)
+                       if (_handle->path) {
                                err = mm_util_encode_bmp_to_file(bmp_data, _handle->path);
-                       else {
-                               image_util_error("Not yet implemented");
-                               return MM_UTIL_ERROR_INVALID_PARAMETER;
+                       } else {
+                               size_t size = 0;
+                               err = mm_util_encode_bmp_to_memory(bmp_data, &(bmp_data->data), &size);
+                               if (err == MM_UTIL_ERROR_NONE)
+                                       bmp_data->size = (unsigned long long)size;
+                               else
+                                       bmp_data->size = 0;
                        }
-
                        if (err == MM_UTIL_ERROR_NONE) {
                                if (_handle->dst_buffer)
                                        *(_handle->dst_buffer) = bmp_data->data;