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..8cbc1b5362 100644 --- a/tools/gtk-image-tool-utils.c +++ b/tools/gtk-image-tool-utils.c @@ -149,6 +149,17 @@ find_color_state_by_name (const char *name) gdk_cicp_params_set_matrix_coefficients (params, 6); gdk_cicp_params_set_range (params, GDK_CICP_RANGE_NARROW); + color_state = gdk_cicp_params_build_color_state (params, &error); + } + else if (g_strcmp0 (name, "jpeg") == 0) + { + params = gdk_cicp_params_new (); + + gdk_cicp_params_set_color_primaries (params, 1); + gdk_cicp_params_set_transfer_function (params, 13); + gdk_cicp_params_set_matrix_coefficients (params, 6); + gdk_cicp_params_set_range (params, GDK_CICP_RANGE_FULL); + color_state = gdk_cicp_params_build_color_state (params, &error); } else if (g_strcmp0 (name, "bt709") == 0) @@ -181,13 +192,34 @@ get_color_state_names (void) static const char *names[] = { "srgb", "srgb-linear", "display-p3", "rec2020", "rec2100-pq", "rec2100-linear", "rec2100-hlg", - "yuv", "bt601", "bt709", + "yuv", "jpeg", "bt601", "bt709", NULL, }; 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 7ad1a61901..12e39dfa37 100644 --- a/tools/gtk-image-tool.h +++ b/tools/gtk-image-tool.h @@ -17,6 +17,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);