From b5336d82cc6e6a035f768f5006503a2891c4f5a6 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 8 Aug 2018 00:51:57 +0200 Subject: png: Read the gamma value if given from the gAMA PNG chunk but not if sRGB mode is already set. --- gdk-pixbuf/io-png.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c index 42fb4fe3b..8a2bf3e02 100644 --- a/gdk-pixbuf/io-png.c +++ b/gdk-pixbuf/io-png.c @@ -256,6 +256,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error) gint num_texts; gchar *key; gchar *value; + gdouble gamma; png_uint_32 x_resolution; png_uint_32 y_resolution; int unit_type; @@ -354,6 +355,17 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error) g_free (icc_profile_base64); } #endif + +#if defined(PNG_READ_gAMA_SUPPORTED) + /* Extract gamma value */ + retval = png_get_gAMA (png_ptr, info_ptr, &gamma); + if (retval != 0) { + char *gamma_str; + gamma_str = g_strdup_printf ("%lf", gamma); + gdk_pixbuf_set_option (pixbuf, "gamma", gamma_str); + g_free (gamma_str); + } +#endif } #ifdef PNG_pHYs_SUPPORTED -- cgit v1.2.1