#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;
}
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 */
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));
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 {
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);
}
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);
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;
}
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;