Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Why same images have different brightness in QtWidgets app and standard Preview app?



  • I wrote some code that show two widgets:

    #include <QtWidgets/QApplication>
    #include <QtWidgets/QLabel>
    #include <QtGui/QPixmap>
    
    #include <QtWidgets/QWidget>
    #include <QtGui/QPalette>
    #include <QtGui/QPixmap>
    #include <QtGui/QBrush>
    
    int main(int argc, char** argv)
    {
        QApplication app(argc, argv);
    
        QPixmap pix;
        pix.load(":/mira.jpg");
    
        QLabel lbl;
        lbl.resize(pix.size());
        lbl.setPixmap(pix);
        lbl.show();
    
        QWidget wgt;
        QPixmap pix2;
        pix2.load(":/mira.jpg");
        QPalette pal;
        pal.setBrush(wgt.backgroundRole(), pix);
        wgt.setPalette(pal);
        wgt.setAutoFillBackground(true);
        wgt.resize(pix2.size());
        wgt.show();
    
        return app.exec();
    }
    

    But I noticed that brightness of the image displayed by this widgets and brightness of the same image displayed by standard macOs Preview.app is slightly differ:
    alt text
    It's not an illusion, I checked it with macOS tool DigitalColorimetor.app and brightness is realy differ, thats true!

    Why same images have different brightness in QtWidgets app and standard Preview app? Which image representation is true?

    UPD: I hope that anyone who understands this will be interested in and check that the decoding of jpg images by the Qt library is correct. By the way, Google Chrome displays photos with the same brightness as Preview, and it does not matter which application is in the input focus.

    Obviously Qt does something wrong
    UPD: image opened in (left to right) Preview.app, Qt Creator (Resource View), Google Chrome
    alt text



  • I think it's a matter of color space .
    In Preview you can choose a color profil. Have a try with sRGB, it could match because it looks darker.
    Also, in Preview you can know what is the embedded image's profil in the Inspector window.



  • @mpergand
    this image opened in Google Chrome has same brightness as in the Preview.app
    I tried to change color schemes on macOS via settings->monitors->colors but difference in brightness is present


Log in to reply