[Qt-interest] pc vs mac color differences (gamma correcting qcolor?)

Ross Bencina rossb-lists at audiomulch.com
Thu Jun 18 09:42:52 CEST 2009


Hi Guys

I run Windows and OSX on the same computer using BootCamp. On each OS, on 
exactly the same screen, colours displayed in my Qt app look different. This 
is a problem since I have invested in having a custom colour scheme designed 
for my app and I would like it to look just as good on both platforms.

I have experimented with gamma correcting each QColor in my QPalette but it 
doesn't seem to work very well -- possibly because my gamma correction code 
is wrong (see below for interest).

Has anyone solved this problem? Do you have any suggestions about how to 
approach it?

/// try to convert a QColor which looks correct on PC to something which 
looks correct on OSX
/// (not working very well)
static QColor pcColor( int rr, int gg, int bb, int aa=255 )
{
 QColor c(rr,gg,bb,aa);
 static const double m = 1.8/2.2;
 qreal r = std::pow( c.redF(), m );
 qreal g = std::pow( c.greenF(), m );
 qreal b = std::pow( c.blueF(), m );

 return QColor::fromRgbF( r, g, b, c.alphaF() );
}



Thanks!

Ross. 




More information about the Qt-interest-old mailing list