Ok, this is the actual correct patch.
-Charles
--- ../moo/qt-x11-free-3.3.5/src/kernel/qpngio.cpp 2005-09-02 13:43:05.000000000 +0100 +++ src/kernel/qpngio.cpp 2005-10-21 14:57:52.000000000 +0100 @@ -110,12 +110,20 @@ static void setup_qt( QImage& image, png_structp png_ptr, png_infop info_ptr, float screen_gamma=0.0 ) { - if ( screen_gamma != 0.0 && png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA) ) { - double file_gamma; - png_get_gAMA(png_ptr, info_ptr, &file_gamma); - png_set_gamma( png_ptr, screen_gamma, file_gamma ); - } - + if ( screen_gamma < 0.0 ) + // PNG docs say this is a good guess for a PC monitor + // in a dark room + screen_gamma = 2.2; + if ( png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA) ) { + // the file has a gAMA attribute + double file_gamma; + if ( png_get_gAMA(png_ptr, info_ptr, &file_gamma)) + png_set_gamma( png_ptr, screen_gamma, file_gamma ); + } else { + // no file gamma, use a reasonable default + png_set_gamma( png_ptr, screen_gamma, 0.0 ); + } + png_uint_32 width; png_uint_32 height; int bit_depth;