Qt 5.3.2 QPainter::SmoothPixmapTransform doesn't do anything



  • I've noticed that the QPainter::SmoothPixmapTransform doesn't seem to do anything and it's making scaled things look horrid. Is there some kind of workaround for this issue?

    Here is a simple example:

    Canvas.h
    @#ifndef CANVAS_H
    #define CANVAS_H

    #include <QtGui>
    //#include <QtWidgets>

    class Canvas : public QWidget
    {
    Q_OBJECT

    private:
    QPixmap *p;

    public:
    Canvas()
    {
    p = new QPixmap(301,301);
    p->fill(Qt::transparent);

    QPainter paint;
    paint.begin(p);

    paint.setRenderHint(QPainter::Antialiasing);
    paint.setRenderHint(QPainter::HighQualityAntialiasing);

    for(int x=0; x<p->width(); x+=10)
    {
    paint.drawLine(x,0, p->width()/2, p->height());
    }
    paint.end();
    }

    void paintEvent(QPaintEvent *e)
    {
    QPainter paint;
    paint.begin(this);
    paint.setRenderHint(QPainter::SmoothPixmapTransform);
    paint.scale(0.25, 0.25);
    paint.drawPixmap(0,0, *p);
    paint.end();
    }
    };

    #endif // CANVAS_H@

    main.cpp
    @//#include <QtWidgets>
    #include <QtGui>
    #include "Canvas.h"

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);

    Canvas canvas;

    canvas.show();

    return app.exec();
    }@

    Here's a sample of the output from both Qt4 and Qt5:
    !http://s14.postimg.org/ti5lqq4fl/Qt4_vs_Qt5.png(Qt4 vs Qt5)!


  • Lifetime Qt Champion

    Hi,

    Not really an answer, but I wonder if it relates to this "bug report":https://bugreports.qt-project.org/browse/QTBUG-40546



  • That bug seems to have been closed for no reason so I created one specific to my problem.

    If you would be so kind, please sign onto this one. It's a very important issue that will unfortunately prevent me from migrating to Qt5.

    https://bugreports.qt-project.org/browse/QTBUG-42330

    OR if there's a workaround, I'd love to know about it.



  • So I've been exploring QTBUGS and there are quite a few similar bug reports.

    Gunnar Sletta mentions in other bug reports that the SmoothPixmapTransform flag should be ignored if the scale is below 0.5 citing performance reasons. I have not noticed any performance issues in Qt4 with SmoothPixmapTransform and scaling below 0.5.

    I'm totally willing to undo this 0.5 scale conditional but can't seem to find it. Might anybody know how/where it's hiding?

    Is there a way to look up commits by Gunnar Sletta?


  • Lifetime Qt Champion

    Sure:

    @git --log --author "Gunnar Sletta"@

    Gunnar knows what he talks about. By the way, the answer to the bug report you cited shows the answer, though not the one you'd like: the paint engine has changed between Qt 4 and 5



  • Yes, I understand that Gunnar knows what he's doing. I have revised my last post to show a little less zeal and a little more respect (I hope).

    I have been pouring over Qt4 and Qt5 source files. It looks like many Mac-specific drawing stuff has been removed in Qt5.

    I'm just hoping there's some way to somehow reintroduce Apple's superior scaling quality. He mentions that QImage has similar capabilities so maybe it can be implemented in QPainter.

    Doesn't everybody agree that the new "raster" scaling looks horrible?



  • As I mentioned in my last comment on the QTBUG-42330: optimized, high-quality rendering has been lost on Qt for Mac.

    Perhaps someone with native OS X API experience might be able to fix it one day but I don't have the chops for it.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.