INCLUDE_DIRECTORIES(${INC_DIR})
# for package file
-SET(dependents "dlog mmutil-magick mmutil-common mmutil-gif mmutil-jpeg mmutil-imgp mmutil-anim mmutil-heif capi-base-common capi-media-tool glib-2.0")
+SET(dependents "dlog mmutil-magick mmutil-common mmutil-gif mmutil-jpeg mmutil-imgp mmutil-anim mmutil-heif mmutil-jxl capi-base-common capi-media-tool glib-2.0")
SET(pc_dependents "capi-base-common capi-media-tool")
INCLUDE(FindPkgConfig)
pkg_check_modules(${fw_name} REQUIRED ${dependents})
* @section CAPI_MEDIA_IMAGE_UTIL_MODULE_ENCODE_DECODE_OVERVIEW Overview
*
* Image Util API provides support for encoding and decoding of images. The API allows :
- *- Encoding of a JPEG/PNG/GIF/BMP and WEBP(Since 6.0) image.
- *- Decoding of a JPEG/PNG/GIF/BMP/WEBP(Since 6.0) and HEIF(Since 6.5) image.
- * Encoding supports gif images including the animated, but decoding gif does not support the animated.
+ * <div><table class="doxtable" >
+ * <tr>
+ * <th><b>Formats</b></th>
+ * <th><b>Encoding</b></th>
+ * <th><b>Decoding</b></th>
+ * <th><b>Remarks</b></th>
+ * </tr>
+ * <tr>
+ * <td>JPEG</td>
+ * <td>O</td>
+ * <td>O</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>PNG</td>
+ * <td>O</td>
+ * <td>O</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>GIF</td>
+ * <td>O</td>
+ * <td>O</td>
+ * <td>Encoding supports gif images including the animated, but decoding gif does not support the animated.</td>
+ * </tr>
+ * <tr>
+ * <td>BMP</td>
+ * <td>O</td>
+ * <td>O</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>WEBP</td>
+ * <td>O</td>
+ * <td>O</td>
+ * <td>Since 6.0</td>
+ * </tr>
+ * <tr>
+ * <td>HEIC</td>
+ * <td></td>
+ * <td>O</td>
+ * <td>Since 6.5</td>
+ * </tr>
+ * <tr>
+ * <td>JPEG-XL</td>
+ * <td>O</td>
+ * <td>O</td>
+ * <td>Since 7.0</td>
+ * </tr>
+ *</table></div>
*
- * The decoding of a jpeg/png/gif/bmp/webp/heif image located at a given path, to a buffer can be done by calling #image_util_decode_run() function and decoding of a jpeg/png/gif/bmp/webp/heif image on memory
+ * The decoding of a jpeg/png/gif/bmp/webp/heif/jpeg-xl image located at a given path, to a buffer can be done by calling #image_util_decode_run() function and decoding of a jpeg/png/gif/bmp/webp/heif/jpeg-xl image on memory
* can be done by calling #image_util_decode_set_output_buffer(). Similarly, for encoding #image_util_encode_run() and #image_util_encode_set_output_buffer() functions can be called
- * to encode an image buffer to a jpeg/png/gif/bmp/webp image and a buffer respectively.
+ * to encode an image buffer to a jpeg/png/gif/bmp/webp/jpeg-xl image and a buffer respectively.
*
* @subsection CAPI_MEDIA_IMAGE_UTIL_ENCODE_DECODE_FOREACH_OPERATIONS Foreach Operations
* <div><table class="doxtable" >
* %http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
* Finds out image type by reading the header of the image provided in input path.\n
* Since 6.0, this module supports WEBP image format.\n
-* Since 6.5, this module supports HEIF image format.
+* Since 6.5, this module supports HEIF image format.\n
+* Since 7.0, this module supports JPEG-XL image format.
*
* @param[in] handle The handle of image util decoding
* @param[in] path The path to input image
* If both are set then the latest input set, is considered.\n
* Finds out image type by reading the header of the image provided in input buffer.\n
* Since 6.0, this module supports WEBP image format.\n
-* Since 6.5, this module supports HEIF image format.
+* Since 6.5, this module supports HEIF image format.\n
+* Since 7.0, this module supports JPEG-XL image format.
*
* @param[in] handle The handle of image util decoding
* @param[in] src_buffer The input image buffer
int image_util_encode_set_png_compression(image_util_encode_h handle, image_util_png_compression_e compression);
/**
+* @deprecated Deprecated since 7.0. Use image_util_encode_set_lossless() instead.
* @brief Sets lossless compression of WEBP images.
* @since_tizen 6.0
*
-* @remarks If application does not set this, then the default value is false.
+* @remarks If application does not set this, then the default value is @c false.
*
* @param[in] handle The handle of image util encoding
-* @param[in] lossless The flag determining whether the compression is lossless or lossy: true for lossless, false for lossy
+* @param[in] lossless The flag determining whether the compression is lossless or lossy: @c true for lossless, @c false for lossy
+*
+* @return @c 0 on success,
+* otherwise a negative error value
+*
+* @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 Not supported format
+*
+* @pre image_util_encode_create()
+*
+* @post image_util_encode_run() / image_util_encode_run_async()
+* @post image_util_encode_destroy()
+*
+* @see image_util_encode_create()
+* @see image_util_encode_run_to_file()
+* @see image_util_encode_run_to_buffer()
+* @see image_util_encode_run_async_to_file()
+* @see image_util_encode_run_async_to_buffer()
+* @see image_util_encode_destroy()
+*/
+int image_util_encode_set_webp_lossless(image_util_encode_h handle, bool lossless) TIZEN_DEPRECATED_API;
+
+/**
+* @brief Sets lossless compression of WEBP and JPEG-XL images.
+* @since_tizen 7.0
+*
+* @remarks If application does not set this, then the default value is @c false.
+*
+* @param[in] handle The handle of image util encoding
+* @param[in] lossless The flag determining whether the compression is lossless or lossy: @c true for lossless, @c false for lossy
*
* @return @c 0 on success,
* otherwise a negative error value
* @see image_util_encode_run_async_to_buffer()
* @see image_util_encode_destroy()
*/
-int image_util_encode_set_webp_lossless(image_util_encode_h handle, bool lossless);
+int image_util_encode_set_lossless(image_util_encode_h handle, bool lossless);
/**
* @deprecated Deprecated since 5.5. Use image_util_agif_encode_add_frame() instead.
* Before 6.0, #IMAGE_UTIL_COLORSPACE_RGBA8888 was the only supported colorspace for PNG. But since 6.0, this module supports more colorspaces for PNG.
* To get supported colorspaces for PNG, you can use image_util_foreach_supported_colorspace().\n
* Since 6.0, this module supports WEBP, you can use image_util_foreach_supported_colorspace() to get supported colorspaces for WEBP.\n
+* Since 7.0, this module supports JPEG-XL, you can use image_util_foreach_supported_colorspace() to get supported colorspaces for JPEG-XL.
*
* @param[in] handle The handle of image util encoding
* @param[in] image The image handle for encoding
* Before 6.0, #IMAGE_UTIL_COLORSPACE_RGBA8888 was the only supported colorspace for PNG. But since 6.0, this module supports more colorspaces for PNG.
* To get supported colorspaces for PNG, you can use image_util_foreach_supported_colorspace().\n
* Since 6.0, this module supports WEBP, you can use image_util_foreach_supported_colorspace() to get supported colorspaces for WEBP.\n
+* Since 7.0, this module supports JPEG-XL, you can use image_util_foreach_supported_colorspace() to get supported colorspaces for JPEG-XL.
*
* @param[in] handle The handle of image util encoding
* @param[in] image The image handle for encoding
* Before 6.0, #IMAGE_UTIL_COLORSPACE_RGBA8888 was the only supported colorspace for PNG. But since 6.0, this module supports more colorspaces for PNG.
* To get supported colorspaces for PNG, you can use image_util_foreach_supported_colorspace().\n
* Since 6.0, this module supports WEBP, you can use image_util_foreach_supported_colorspace() to get supported colorspaces for WEBP.\n
+* Since 7.0, this module supports JPEG-XL, you can use image_util_foreach_supported_colorspace() to get supported colorspaces for JPEG-XL.
*
* @param[in] handle The handle of image util encoding
* @param[in] image The image handle for encoding
* Before 6.0, #IMAGE_UTIL_COLORSPACE_RGBA8888 was the only supported colorspace for PNG. But since 6.0, this module supports more colorspaces for PNG.
* To get supported colorspaces for PNG, you can use image_util_foreach_supported_colorspace().\n
* Since 6.0, this module supports WEBP, you can use image_util_foreach_supported_colorspace() to get supported colorspaces for WEBP.\n
+* Since 7.0, this module supports JPEG-XL, you can use image_util_foreach_supported_colorspace() to get supported colorspaces for JPEG-XL.
*
* @param[in] handle The handle of image util encoding
* @param[in] image The image handle for encoding
} transformation_s;
#define IMAGE_UTIL_TYPE_CHECK(type) \
- image_util_retvm_if((type < IMAGE_UTIL_JPEG || type > IMAGE_UTIL_HEIF), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image type [%d]", type)
+ image_util_retvm_if((type < IMAGE_UTIL_JPEG || type > IMAGE_UTIL_JPEG_XL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid image type [%d]", type)
#define IMAGE_UTIL_SUPPORT_TYPE_CHECK(value, support) \
image_util_retvm_if((value != support), IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT, "Not supported format")
* @since_tizen 3.0
*/
typedef enum {
- IMAGE_UTIL_JPEG, /**< Image format JPEG */
- IMAGE_UTIL_PNG, /**< Image format PNG */
- IMAGE_UTIL_GIF, /**< Image format GIF */
- IMAGE_UTIL_BMP, /**< Image format BMP */
- IMAGE_UTIL_WEBP, /**< Image format WEBP (Since 6.0) */
- IMAGE_UTIL_HEIF, /**< Image format HEIF (Since 6.5) */
+ IMAGE_UTIL_JPEG, /**< Image format JPEG */
+ IMAGE_UTIL_PNG, /**< Image format PNG */
+ IMAGE_UTIL_GIF, /**< Image format GIF */
+ IMAGE_UTIL_BMP, /**< Image format BMP */
+ IMAGE_UTIL_WEBP, /**< Image format WEBP (Since 6.0) */
+ IMAGE_UTIL_HEIF, /**< Image format HEIF (Since 6.5) */
+ IMAGE_UTIL_JPEG_XL, /**< Image format JPEG-XL (Since 7.0) */
} image_util_type_e;
/**
Name: capi-media-image-util
Summary: A Image Utility library in Tizen Native API
-Version: 0.3.3
+Version: 0.4.0
Release: 0
Group: Multimedia/API
License: Apache-2.0
BuildRequires: pkgconfig(mmutil-magick)
BuildRequires: pkgconfig(mmutil-anim)
BuildRequires: pkgconfig(mmutil-heif)
+BuildRequires: pkgconfig(mmutil-jxl)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(capi-media-tool)
BuildRequires: pkgconfig(glib-2.0)
#include <mm_util_magick.h>
#include <mm_util_image.h>
#include <mm_util_heif.h>
+#include <mm_util_jxl.h>
#include <image_util.h>
#include <image_util_private.h>
static unsigned char _BMP_HEADER[] = { 'B', 'M' };
static unsigned char _WEBP_HEADER[] = { 0x57, 0x45, 0x42, 0x50 };
static unsigned char _HEIF_HEADER[] = { 'f', 't', 'y', 'p' };
+ static unsigned char _JXL_HEADER[] = { 'J', 'X', 'L'};
+ static unsigned char _JXL_CODESTREAM_HEADER[] = { 0xFF, 0x0A }; // if image start with codestream without JXL container
static struct {
image_util_type_e image_type;
{ IMAGE_UTIL_BMP, _BMP_HEADER, sizeof(_BMP_HEADER), 0 },
{ IMAGE_UTIL_WEBP, _WEBP_HEADER, sizeof(_WEBP_HEADER), 8 },
{ IMAGE_UTIL_HEIF, _HEIF_HEADER, sizeof(_HEIF_HEADER), 4 },
+ { IMAGE_UTIL_JPEG_XL, _JXL_HEADER, sizeof(_JXL_HEADER), 4 },
+ { IMAGE_UTIL_JPEG_XL, _JXL_CODESTREAM_HEADER, sizeof(_JXL_CODESTREAM_HEADER), 0 },
};
unsigned int i = 0;
}
break;
+ case IMAGE_UTIL_JPEG_XL:
+ {
+ if (_handle->path)
+ err = mm_util_decode_jxl_from_file(_handle->path, colorspace, image_info);
+ else
+ err = mm_util_decode_jxl_from_buffer(_handle->src_buffer, _handle->src_size, colorspace, image_info);
+ }
+ break;
+
default:
image_util_error("Not supported format [%d]", _handle->image_type);
return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
ret = mm_util_decode_heif_from_file(file_path, colorspace, image);
break;
+ case IMAGE_UTIL_JPEG_XL:
+ ret = mm_util_decode_jxl_from_file(file_path, colorspace, image);
+ break;
+
default:
image_util_error("Not supported format [%d]", image_type);
return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
ret = mm_util_decode_heif_from_buffer((void *)buffer, buffer_size, colorspace, image);
break;
+ case IMAGE_UTIL_JPEG_XL:
+ ret = mm_util_decode_jxl_from_buffer((void *)buffer, buffer_size, colorspace, image);
+ break;
+
default:
image_util_error("Not supported format [%d]", image_type);
return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
#include <mm_util_magick.h>
#include <mm_util_image.h>
#include <mm_util_anim.h>
+#include <mm_util_jxl.h>
#include <image_util.h>
#include <image_util_private.h>
{
encode_s *_handle = (encode_s *) handle;
+ image_util_warning("DEPRECATION WARNING: image_util_encode_set_webp_lossless() is deprecated and will be removed from next release. Use image_util_encode_set_lossless() instead.");
+
+ image_util_retvm_if(!_handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
+ IMAGE_UTIL_SUPPORT_TYPE_CHECK(_handle->image_type, IMAGE_UTIL_WEBP);
+
+ return _image_error_capi(mm_util_enc_opt_set_lossless(_handle->enc_opt, lossless));
+}
+
+int image_util_encode_set_lossless(image_util_encode_h handle, bool lossless)
+{
+ encode_s *_handle = (encode_s *) handle;
+
image_util_retvm_if(!_handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
- return _image_error_capi(mm_util_enc_opt_set_webp_lossless(_handle->enc_opt, lossless));
+ return _image_error_capi(mm_util_enc_opt_set_lossless(_handle->enc_opt, lossless));
}
int image_util_encode_set_gif_frame_delay_time(image_util_encode_h handle, unsigned long long delay_time)
else
err = mm_util_encode_image_to_buffer(_src, _handle->enc_opt, _handle->dst_buffer, &_handle->dst_size);
break;
+ case IMAGE_UTIL_JPEG_XL:
+ if (_handle->path)
+ err = mm_util_encode_jxl_to_file(_src, _handle->enc_opt, _handle->path);
+ else
+ err = mm_util_encode_jxl_to_buffer(_src, _handle->enc_opt, _handle->dst_buffer, &_handle->dst_size);
+ break;
default:
image_util_error("Invalid image_type %d", _handle->image_type);
mm_image_destroy_image(_src);
ret = mm_util_encode_image_to_file(image, _handle->enc_opt, file_path);
break;
+ case IMAGE_UTIL_JPEG_XL:
+ ret = mm_util_encode_jxl_to_file(image, _handle->enc_opt, file_path);
+ break;
+
default:
return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
break;
case IMAGE_UTIL_WEBP:
ret = mm_util_encode_image_to_buffer(image, _handle->enc_opt, (void **)buffer, buffer_size);
break;
+
+ case IMAGE_UTIL_JPEG_XL:
+ ret = mm_util_encode_jxl_to_buffer(image, _handle->enc_opt, (void **)buffer, buffer_size);
+ break;
+
default:
return IMAGE_UTIL_ERROR_INVALID_PARAMETER;
break;
[IMAGE_UTIL_COLORSPACE_NV61] = _NOT_SUPPORTED_COLORSPACE,
};
+static int _convert_jxl_colorspace_tbl[] = {
+ [IMAGE_UTIL_COLORSPACE_YV12] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_YUV422] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_I420] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_NV12] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_UYVY] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_YUYV] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_RGB565] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_RGB888] = MM_UTIL_COLOR_RGB24,
+ [IMAGE_UTIL_COLORSPACE_ARGB8888] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_BGRA8888] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_RGBA8888] = MM_UTIL_COLOR_RGBA,
+ [IMAGE_UTIL_COLORSPACE_BGRX8888] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_NV21] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_NV16] = _NOT_SUPPORTED_COLORSPACE,
+ [IMAGE_UTIL_COLORSPACE_NV61] = _NOT_SUPPORTED_COLORSPACE,
+};
+
unsigned int _get_number_of_colorspace(void)
{
return G_N_ELEMENTS(_convert_colorspace_tbl);
case IMAGE_UTIL_HEIF:
image_util_retvm_if((_convert_heif_colorspace_tbl[colorspace] == _NOT_SUPPORTED_COLORSPACE), FALSE, "[heif] %d not supported format", colorspace);
break;
+ case IMAGE_UTIL_JPEG_XL:
+ image_util_retvm_if((_convert_jxl_colorspace_tbl[colorspace] == _NOT_SUPPORTED_COLORSPACE), FALSE, "[jpeg-xl] %d not supported format", colorspace);
+ break;
default:
image_util_retvm_if(TRUE, FALSE, "Invalid image type");
}
case IMAGE_UTIL_HEIF:
new_colorspace = _convert_heif_colorspace_tbl[colorspace];
break;
+ case IMAGE_UTIL_JPEG_XL:
+ new_colorspace = _convert_jxl_colorspace_tbl[colorspace];
+ break;
default:
image_util_error("Invalid image type");
}
#include <image_util_private.h>
/* logs for testsuite */
-#define VERSION "0.1.1 of 16 Aug 2019"
+#define VERSION "0.1.2 of 13 Apr 2022"
/* prints log of menu-queue for testsuite */
#define DEBUG_QUEUE 0 /* 0:disable, 1:enable */
/* saves the intermediate image to process name("transform" or "decode"), Not supported for encoding */
g_print("*** input %s: ", text);
}
+typedef struct {
+ unsigned int e;
+ const char *t;
+} test_menu_s;
+
typedef enum {
RAW_IMG_SET_COLOR,
RAW_IMG_SET_SIZE,
RAW_IMG_MENU_MAX,
} test_raw_img_menu_e;
-typedef struct {
- test_raw_img_menu_e e;
- const char *t;
-} test_raw_img_menu_s;
-
-static const test_raw_img_menu_s g_disp_raw_img_menu[RAW_IMG_MENU_MAX] = {
+static const test_menu_s g_disp_raw_img_menu[RAW_IMG_MENU_MAX] = {
{ RAW_IMG_SET_COLOR, "set colorspace (opt. default=IMAGE_UTIL_COLORSPACE_RGBA8888)" },
{ RAW_IMG_SET_SIZE, "set width & height" },
};
g_print("====================================================\n");
g_print(" image-util Core-API test: Set raw data menu v%s\n", VERSION);
g_print("----------------------------------------------------\n");
- for (idx = 0; idx < RAW_IMG_MENU_MAX; idx++)
+ for (idx = 0; idx < G_N_ELEMENTS(g_disp_raw_img_menu); idx++)
g_print("%u. %s\n", g_disp_raw_img_menu[idx].e, g_disp_raw_img_menu[idx].t);
g_print("b. back\n");
g_print("q. quit\n");
DECODE_MENU_MAX,
} test_decode_menu_e;
-typedef struct {
- test_decode_menu_e e;
- const char *t;
-} test_decode_menu_s;
-
-static const test_decode_menu_s g_disp_decode_menu[DECODE_MENU_MAX] = {
+static const test_menu_s g_disp_decode_menu[DECODE_MENU_MAX] = {
{ DECODE_SET_BUFFER, "set input buffer" },
{ DECODE_SET_COLOR, "set color (mand. default=IMAGE_UTIL_COLORSPACE_RGBA8888)" },
{ DECODE_SET_DOWNSCALE, "set downscale (opt. for jpeg only)" },
g_print("====================================================\n");
g_print(" image-util Core-API test: Decode menu v%s\n", VERSION);
g_print("----------------------------------------------------\n");
- for (idx = 0; idx < DECODE_MENU_MAX; idx++)
+ for (idx = 0; idx < G_N_ELEMENTS(g_disp_decode_menu); idx++)
g_print("%u. %s\n", g_disp_decode_menu[idx].e, g_disp_decode_menu[idx].t);
g_print("b. back\n");
g_print("q. quit\n");
ENCODE_MENU_MAX,
} test_encode_menu_e;
-typedef struct {
- test_encode_menu_e e;
- const char *t;
-} test_encode_menu_s;
-
-static const test_encode_menu_s g_disp_encode_menu[ENCODE_MENU_MAX] = {
+static const test_menu_s g_disp_encode_menu[ENCODE_MENU_MAX] = {
{ ENCODE_SET_TYPE, "set image_type (mand. default=IMAGE_UTIL_JPEG)" },
{ ENCODE_SET_QUALITY, "set quality (opt. for jpeg only)" },
{ ENCODE_SET_COMPRESIION, "set compression (opt. for png only)" },
- { ENCODE_SET_LOSSLESS, "set lossless (opt. for webp only)" },
+ { ENCODE_SET_LOSSLESS, "set lossless (opt. for webp & jpeg-xl)" },
{ ENCODE_SET_TO_BUFFER, "set output buffer (opt. deprecated)" },
{ ENCODE_RUN, "encode run (will be deprecated)" },
{ ENCODE_RUN_ASYNC, "encode run async (will be deprecated)" },
g_print("====================================================\n");
g_print(" image-util Core-API test: Encode menu v%s\n", VERSION);
g_print("----------------------------------------------------\n");
- for (idx = 0; idx < ENCODE_MENU_MAX; idx++)
+ for (idx = 0; idx < G_N_ELEMENTS(g_disp_encode_menu); idx++)
g_print("%u. %s\n", g_disp_encode_menu[idx].e, g_disp_encode_menu[idx].t);
g_print("b. back\n");
g_print("q. quit\n");
ENCODE_AGIF_MENU_MAX,
} test_encode_agif_menu_e;
-typedef struct {
- test_encode_agif_menu_e e;
- const char *t;
-} test_encode_agif_menu_s;
-
-static const test_encode_agif_menu_s g_disp_encode_agif_menu[ENCODE_AGIF_MENU_MAX] = {
+static const test_menu_s g_disp_encode_agif_menu[ENCODE_AGIF_MENU_MAX] = {
{ ENCODE_AGIF_SET_DIR, "set directory" },
{ ENCODE_AGIF_SET_DELAY, "set delay time (mand. default = 100)" },
{ ENCODE_AGIF_SET_TO_BUFFER, "set output buffer (opt. will be deprecated)" },
g_print("====================================================\n");
g_print(" image-util Core-API test: Encode A-GIF menu v%s\n", VERSION);
g_print("----------------------------------------------------\n");
- for (idx = 0; idx < ENCODE_AGIF_MENU_MAX; idx++)
+ for (idx = 0; idx < G_N_ELEMENTS(g_disp_encode_agif_menu); idx++)
g_print("%u. %s\n", g_disp_encode_agif_menu[idx].e, g_disp_encode_agif_menu[idx].t);
g_print("b. back\n");
g_print("q. quit\n");
ENCODE_ANIM_MENU_MAX,
} test_encode_anim_menu_e;
-typedef struct {
- test_encode_anim_menu_e e;
- const char *t;
-} test_encode_anim_menu_s;
-
-static const test_encode_anim_menu_s g_disp_encode_anim_menu[ENCODE_ANIM_MENU_MAX] = {
+static const test_menu_s g_disp_encode_anim_menu[ENCODE_ANIM_MENU_MAX] = {
{ ENCODE_ANIM_SET_DIR, "set directory" },
{ ENCODE_ANIM_SET_TYPE, "set animation type (mand. default = webp)" },
{ ENCODE_ANIM_SET_DELAY, "set delay time (mand. default = 100)" },
g_print("====================================================\n");
g_print(" image-util Core-API test: Encode ANIMATION menu v%s\n", VERSION);
g_print("----------------------------------------------------\n");
- for (idx = 0; idx < ENCODE_ANIM_MENU_MAX; idx++)
+ for (idx = 0; idx < G_N_ELEMENTS(g_disp_encode_anim_menu); idx++)
g_print("%u. %s\n", g_disp_encode_anim_menu[idx].e, g_disp_encode_anim_menu[idx].t);
g_print("b. back\n");
g_print("q. quit\n");
TRANSFORM_MENU_MAX,
} test_transform_menu_e;
-typedef struct {
- test_transform_menu_e e;
- const char *t;
-} test_transform_menu_s;
-
-static const test_transform_menu_s g_disp_transform_menu[TRANSFORM_MENU_MAX] = {
+static const test_menu_s g_disp_transform_menu[TRANSFORM_MENU_MAX] = {
{ TRANSFORM_SET_CONVERT, "set convert" },
{ TRANSFORM_SET_CROP, "set crop" },
{ TRANSFORM_SET_RESIZE, "set resize" },
g_print("====================================================\n");
g_print(" image-util Core-API test: Transform menu v%s\n", VERSION);
g_print("----------------------------------------------------\n");
- for (idx = 0; idx < TRANSFORM_MENU_MAX; idx++)
+ for (idx = 0; idx < G_N_ELEMENTS(g_disp_transform_menu); idx++)
g_print("%u. %s\n", g_disp_transform_menu[idx].e, g_disp_transform_menu[idx].t);
g_print("b. back\n");
g_print("q. quit\n");
MAIN_MENU_MAX,
} test_main_menu_e;
-typedef struct {
- test_main_menu_e e;
- const char *t;
-} test_main_menu_s;
-
-static const test_main_menu_s g_disp_main_menu[MAIN_MENU_MAX] = {
+static const test_menu_s g_disp_main_menu[MAIN_MENU_MAX] = {
{ TEST_AUTO, "test auto" },
{ TEST_DECODE, "test decode" },
{ TEST_ENCODE, "test encode" },
g_print("====================================================\n");
g_print(" image-util Core-API test: Main menu v%s\n", VERSION);
g_print("----------------------------------------------------\n");
- for (idx = 0; idx < MAIN_MENU_MAX; idx++)
+ for (idx = 0; idx < G_N_ELEMENTS(g_disp_main_menu); idx++)
g_print("%u. %s\n", g_disp_main_menu[idx].e, g_disp_main_menu[idx].t);
g_print("q. quit\n");
g_print("----------------------------------------------------\n");
__display_set("rotation", "0:none, 1:90, 2:180, 3:270");
break;
case SET_TYPE_MENU:
- __display_set("image_type", "0:jpeg, 1:png, 2:gif, 3:bmp, 4:webp");
+ __display_set("image_type", "0:jpeg, 1:png, 2:gif, 3:bmp, 4:webp, 6:jpeg-xl");
break;
case SET_ANIM_TYPE_MENU:
__display_set("image_anim_type", "0:gif, 1:webp");
return TRUE;
}
-#if DUMP_RAW_IMAGE
-static int __write_jpeg(const char *name, image_util_image_h image)
+static void __write_jpeg(const char *name, image_util_image_h image)
{
int ret = IMAGE_UTIL_ERROR_NONE;
image_util_encode_h handle = NULL;
ret = image_util_encode_create(IMAGE_UTIL_JPEG, &handle);
if (ret != IMAGE_UTIL_ERROR_NONE) {
g_print("image_util_decode_create failed %d", ret);
- return ret;
+ goto ERROR;
}
ret = image_util_encode_run_to_file(handle, image, path);
ERROR:
image_util_encode_destroy(handle);
+ g_free(path);
- return ret;
+ g_print("\t[__write_jpeg] %s write %s\n", name, (ret == IMAGE_UTIL_ERROR_NONE) ? "DONE" : "FAIL");
}
-#endif
static gboolean __safe_atoui(char *buffer, unsigned int *ui)
{
"gif",
"bmp",
"webp",
+ "", // not supported HEIF
+ "jxl",
};
static void __get_auto_path(image_util_type_e image_type, char **path)
{
char *_path = NULL;
- switch (image_type) {
- case IMAGE_UTIL_JPEG:
- /* fall through */
- case IMAGE_UTIL_PNG:
- /* fall through */
- case IMAGE_UTIL_GIF:
- /* fall through */
- case IMAGE_UTIL_BMP:
- /* fall through */
- case IMAGE_UTIL_WEBP:
- // do noting...
- break;
- default:
- g_print("Not supported encode format!\n");
+ if (!g_image_exts[image_type] || (strlen(g_image_exts[image_type]) == 0)) {
+ g_print("Not supported image_type[%d]!\n", image_type);
return;
}
g_free(*path);
*path = _path;
- g_print("\t__get_auto_path: %s!\n", *path);
+ g_print("\t__get_auto_path: %s\n", *path);
}
static void __get_encode_path(image_util_type_e image_type, const char *base, char **path)
{
char *_path = NULL;
- switch (image_type) {
- case IMAGE_UTIL_JPEG:
- /* fall through */
- case IMAGE_UTIL_PNG:
- /* fall through */
- case IMAGE_UTIL_GIF:
- /* fall through */
- case IMAGE_UTIL_BMP:
- /* fall through */
- case IMAGE_UTIL_WEBP:
- // do noting...
- break;
- default:
- g_print("Not supported encode format!\n");
+ if (!g_image_exts[image_type] || (strlen(g_image_exts[image_type]) == 0)) {
+ g_print("Not supported image_type[%d]!\n", image_type);
return;
}
g_free(*path);
*path = _path;
- g_print("\t__get_encode_path: %s!\n", *path);
+ g_print("\t__get_encode_path: %s\n", *path);
}
static const char *g_anim_image_exts[] = {
{
char *_path = NULL;
- switch (anim_type) {
- case IMAGE_UTIL_ANIM_GIF:
- /* fall through */
- case IMAGE_UTIL_ANIM_WEBP:
- // do noting...
- break;
- default:
- g_print("Not supported encode animation format!\n");
+ if (!g_anim_image_exts[anim_type] || (strlen(g_anim_image_exts[anim_type]) == 0)) {
+ g_print("Not supported anim_type[%d]!\n", anim_type);
return;
}
g_free(*path);
*path = _path;
- g_print("\t__get_encode_path: %s!\n", *path);
+ g_print("\t__get_encode_anim_path: %s\n", *path);
}
/* internal functions for testsuite */
}
break;
case IMAGE_UTIL_WEBP:
- ret = image_util_encode_set_webp_lossless(handle, params->lossless);
+ case IMAGE_UTIL_JPEG_XL:
+ ret = image_util_encode_set_lossless(handle, params->lossless);
if (ret != IMAGE_UTIL_ERROR_NONE) {
- g_print("image_util_encode_set_webp_lossless failed %d\n", ret);
+ g_print("image_util_encode_set_lossless failed %d\n", ret);
goto ERROR;
}
break;
__data_push(input_data);
}
break;
+
+ case DECODE_SAVE_TO_JPEG:
+ __write_jpeg("decode", g_decode_result.image);
+ break;
+
default:
g_print("wrong command! %s\n\n", cmd);
break;