For high-level control of gamma, simply add:
PNG_TRANSFORM_SRGB Convert to sRGB gamma
PNG_TRANSFORM_LINEAR Convert to gamma==1.0
In the documentation, note that:
1. sRGB must be used for normal displays
2. linear must be used for most image processing, including
alpha blending and scaling
Logged In: YES
user_id=7859
what should these transforms do when the input file lacks
gamma info?
Logged In: YES
user_id=18352
The best you can do without gamma info is to assume that sRGB
has been used. The vast majority of unmarked images are in this
format. Probably the image was done by eye on a normal display.
This is the case with Tux Paint images for example.
BTW, if gamma is specified and is within a few percent of sRGB,
you might just consider that to be close enough. Probably a
good number of apps are crudely encoding the gamma.