#define WRONG_PATH ""
-#define DECODE_IMAGE_TYPE_N IMAGE_UTIL_WEBP
+#define DECODE_IMAGE_TYPE_N IMAGE_UTIL_HEIF
#define ENCODE_IMAGE_TYPE_N IMAGE_UTIL_WEBP
#define INVALID_IMAGE_TYPE ((DECODE_IMAGE_TYPE_N > ENCODE_IMAGE_TYPE_N) ? DECODE_IMAGE_TYPE_N * 2 : ENCODE_IMAGE_TYPE_N * 2)
[IMAGE_UTIL_GIF] = { true, "sample.gif", true, "test_output.gif" },
[IMAGE_UTIL_BMP] = { true, "sample.bmp", true, "test_output.bmp" },
[IMAGE_UTIL_WEBP] = { true, "sample.webp", true, "test_output.webp" },
+ [IMAGE_UTIL_HEIF] = { true, "sample.heic", false, NULL },
};
typedef struct {
[IMAGE_UTIL_GIF] = { NULL, NULL, NULL, { NULL, 0, 0, 0 } },
[IMAGE_UTIL_BMP] = { NULL, NULL, NULL, { NULL, 0, 0, 0 } },
[IMAGE_UTIL_WEBP] = { NULL, NULL, NULL, { NULL, 0, 0, 0 } },
+ [IMAGE_UTIL_HEIF] = { NULL, NULL, NULL, { NULL, 0, 0, 0 } },
};
typedef struct {
{
int ret = IMAGE_UTIL_ERROR_NONE;
image_util_image_h decoded_image = NULL;
+ GError *error = NULL;
ret = _utc_decode_from_file(utc_decode[type].source, &decoded_image);
if (ret != IMAGE_UTIL_ERROR_NONE) {
return ret;
}
- ret = _utc_encode_to_buffer(type, decoded_image, &utc_encode[type].result.buffer, &utc_encode[type].result.size);
- if (ret != IMAGE_UTIL_ERROR_NONE)
- FPRINTF("[%d:%s] _utc_encode_to_buffer failed! %d \\n", __LINE__, __FUNCTION__, ret);
+ FPRINTF("[%d:%s] decode[%d] buffer: %zu \\n", __LINE__, __FUNCTION__, type, utc_decode[type].result.size);
+
+ if (!g_file_get_contents(utc_decode[type].source, &utc_encode[type].result.buffer, &utc_encode[type].result.size, &error)) {
+ FPRINTF("[%d:%s] g_file_get_contents failed! %s \\n", __LINE__, __FUNCTION__, (error ? error->message : "none"));
+ if (error)
+ g_error_free(error);
+ ret = IMAGE_UTIL_ERROR_INVALID_PARAMETER;
+ }
+
+ FPRINTF("[%d:%s] encode[%d] buffer: %zu \\n", __LINE__, __FUNCTION__, type, utc_encode[type].result.size);
image_util_destroy_image(decoded_image);
}
utc_encode[type].output = _utc_get_test_path(pszValue, UTC_CONFIG[type].output);
- FPRINTF("[%d:%s] PATH [Type: %d] [Decode: %s], [Encode: %s] \\n", __LINE__, __FUNCTION__, type, utc_encode[type].output);
+ FPRINTF("[%d:%s] PATH [Type: %d] [Encode: %s] \\n", __LINE__, __FUNCTION__, type, utc_encode[type].output);
if (!utc_encode[type].output)
FPRINTF("[%d:%s] Get UTC Path error! \\n", __LINE__, __FUNCTION__);