Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt 5.3.2 QPainter::SmoothPixmapTransform doesn't do anything

Qt 5.3.2 QPainter::SmoothPixmapTransform doesn't do anything

Scheduled Pinned Locked Moved General and Desktop
7 Posts 1 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on 31 Oct 2014, 22:18 last edited by
    #1

    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)!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 31 Oct 2014, 23:10 last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • ? This user is from outside of this forum
        ? This user is from outside of this forum
        Guest
        wrote on 1 Nov 2014, 00:56 last edited by
        #3

        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.

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on 1 Nov 2014, 02:33 last edited by
          #4

          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?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 4 Nov 2014, 00:18 last edited by
            #5

            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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • ? This user is from outside of this forum
              ? This user is from outside of this forum
              Guest
              wrote on 4 Nov 2014, 00:31 last edited by
              #6

              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?

              1 Reply Last reply
              0
              • ? This user is from outside of this forum
                ? This user is from outside of this forum
                Guest
                wrote on 4 Nov 2014, 19:04 last edited by
                #7

                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.

                1 Reply Last reply
                0

                2/7

                31 Oct 2014, 23:10

                topic:navigator.unread, 5
                • Login

                • Login or register to search.
                2 out of 7
                • First post
                  2/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved