diff options
author | Bastien Nocera <hadess@hadess.net> | 2018-08-08 00:51:57 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2018-08-08 00:51:57 +0200 |
commit | b5336d82cc6e6a035f768f5006503a2891c4f5a6 (patch) | |
tree | 0ceb53a258a3d888c94d85e0bb86f006f5b0609b /gdk-pixbuf/io-png.c | |
parent | 31e8a43d3359d0d5a3fb7e58edacb046cf6cb8d6 (diff) | |
download | gdk-pixbuf-wip/hadess/read-png-gamma.tar.gz |
png: Read the gamma value if givenwip/hadess/read-png-gamma
from the gAMA PNG chunk but not if sRGB mode is already set.
Diffstat (limited to 'gdk-pixbuf/io-png.c')
-rw-r--r-- | gdk-pixbuf/io-png.c | 12 |
1 files changed, 12 insertions, 0 deletions
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 |