PNG loader ignores gAMA
The simplest fix would be to add the following in cairo-image-surface-png.c, before the call to png_read_info
:
png_set_gamma(cairo_png_data->png_ptr, PNG_DEFAULT_sRGB, PNG_DEFAULT_sRGB);
This converts any images self-declared to have a different gamma curve than sRGB to sRGB's pseudo-2.2.
However, with HAVE_LCMS2
this gets a bit complicated:
An sRGB chunk or iCCP chunk, when present and recognized, overrides the gAMA chunk.
The libpng fix needs to be inside an #ifndef
, and a GthICCProfile
should be generated if the file contains a gAMA chunk, adding another else if
. How to set up Little-CMS to do gamma conversion within sRGB remains an open question.