From 28817b4bb2f4c33500764e3c458fefeec0834e93 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 8 Aug 2024 08:08:23 -0400 Subject: [PATCH 1/2] image tool: Better color state support Show cicp color states with their tuple. --- tools/gtk-image-tool-info.c | 13 ++++++++++++- tools/gtk-image-tool-utils.c | 21 +++++++++++++++++++++ tools/gtk-image-tool.h | 1 + 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/tools/gtk-image-tool-info.c b/tools/gtk-image-tool-info.c index 2f80cb622a..d451718c30 100644 --- a/tools/gtk-image-tool-info.c +++ b/tools/gtk-image-tool-info.c @@ -48,12 +48,23 @@ static void file_info (const char *filename) { GdkTexture *texture; + char *name; + char *cicp; texture = load_image_file (filename); g_print ("%s %dx%d\n", _("Size:"), gdk_texture_get_width (texture), gdk_texture_get_height (texture)); g_print ("%s %s\n", _("Format:"), get_format_name (gdk_texture_get_format (texture))); - g_print ("%s %s\n", _("Color state:"), get_color_state_name (gdk_texture_get_color_state (texture))); + + name = get_color_state_name (gdk_texture_get_color_state (texture)); + cicp = get_color_state_cicp (gdk_texture_get_color_state (texture)); + + if (name && cicp) + g_print ("%s %s (cicp %s)\n", _("Color state:"), name, cicp); + else if (cicp) + g_print ("%s cicp %s\n", _("Color state:"), cicp); + else + g_print ("%s %s\n", _("Color state:"), _("unknown")); g_object_unref (texture); } diff --git a/tools/gtk-image-tool-utils.c b/tools/gtk-image-tool-utils.c index d5a2f1e82c..1a23e744fb 100644 --- a/tools/gtk-image-tool-utils.c +++ b/tools/gtk-image-tool-utils.c @@ -188,6 +188,27 @@ get_color_state_names (void) return g_strdupv ((char **) names); } +char * +get_color_state_cicp (GdkColorState *color_state) +{ + GdkCicpParams *params; + char *str = NULL; + + params = gdk_color_state_create_cicp_params (color_state); + + if (params) + { + str = g_strdup_printf ("%u/%u/%u/%u", + gdk_cicp_params_get_color_primaries (params), + gdk_cicp_params_get_transfer_function (params), + gdk_cicp_params_get_matrix_coefficients (params), + gdk_cicp_params_get_range (params)); + g_object_unref (params); + } + + return str; +} + char * get_color_state_name (GdkColorState *color_state) { diff --git a/tools/gtk-image-tool.h b/tools/gtk-image-tool.h index e5499022d6..afd51310ee 100644 --- a/tools/gtk-image-tool.h +++ b/tools/gtk-image-tool.h @@ -18,6 +18,7 @@ GdkColorState * find_color_state_by_name (const char *name); char ** get_color_state_names (void); char * get_color_state_name (GdkColorState *color_state); +char * get_color_state_cicp (GdkColorState *color_state); GdkColorState *parse_cicp_tuple (const char *cicp_tuple, GError **error); From 34c69b2868012c36bc52d0d8b61c0af3d34ef36b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 5 Oct 2024 08:55:16 -0400 Subject: [PATCH 2/2] build: Don't use / in target names It is unnecessary, and meson doesn't like it. --- tools/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/meson.build b/tools/meson.build index a5cfd739f0..c4c28ffbcf 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -11,7 +11,7 @@ if win32_enabled # compile_resources doesn't like to consume targets with multiple outputs, # and the xxx.exe.manifest and xxx.rc are tied together uac_rc = custom_target( - 'tools/@0@.rc'.format(uac_exe_name), + '@0@-rc'.format(uac_exe_name), output: ['@0@.rc'.format(uac_exe_name)], command: [gen_uac_manifest, '-p=@0@'.format(uac_exe_pkg),