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. QPainter::drawImage() is terrible at smooth scaling?
Forum Updated to NodeBB v4.3 + New Features

QPainter::drawImage() is terrible at smooth scaling?

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 5 Posters 2.6k Views 1 Watching
  • 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.
  • D Offline
    D Offline
    davecotter
    wrote on last edited by
    #1

    when i use drawImage() to do scaling, even having set SmoothPixmapTransform rendering hint, it, well, really sucks. like here look:

    0_1557457383112_Screen Shot 2019-05-09 at 8.00.34 PM.png
    I saw this article that suggests this is expected, and instead I should be using QImage::smoothScaled() to produce the scaled image first, THEN blit with drawImage. Well, yes, the results are as I expected in the first place:

    0_1557457455196_Screen Shot 2019-05-09 at 7.58.50 PM.png
    but I gotta ask: really? this is what is expected? yet another blit in between? That's going to cause a performance hit. Or did i just miss something else i need to do to the QImage or some other render hint i haven't seen?

    jsulmJ 1 Reply Last reply
    0
    • D Offline
      D Offline
      davecotter
      wrote on last edited by
      #11

      got a reply on the mailing list:

      Likes like you are downscaling more than 2x. QPainter is doing bilinear
      sampling when smooth scaling, and that produces bad results at 2x downscaling.
      QImage::smoothScaled() uses a slower box scaling algorithm that works at even
      the most aggressive downscaling.

      :D

      1 Reply Last reply
      1
      • D davecotter

        when i use drawImage() to do scaling, even having set SmoothPixmapTransform rendering hint, it, well, really sucks. like here look:

        0_1557457383112_Screen Shot 2019-05-09 at 8.00.34 PM.png
        I saw this article that suggests this is expected, and instead I should be using QImage::smoothScaled() to produce the scaled image first, THEN blit with drawImage. Well, yes, the results are as I expected in the first place:

        0_1557457455196_Screen Shot 2019-05-09 at 7.58.50 PM.png
        but I gotta ask: really? this is what is expected? yet another blit in between? That's going to cause a performance hit. Or did i just miss something else i need to do to the QImage or some other render hint i haven't seen?

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @davecotter Can't you do the scaling once and store the scaled image for drawing?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        3
        • D Offline
          D Offline
          davecotter
          wrote on last edited by davecotter
          #3

          my question is: is this expected?

          to answer your Q: no, i gave this icon thing as an example, but this is a video app, i need the fastest framerates possible, and blitting twice is always more expensive than blitting once.

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            I would even trying to output video without using e.g. OpenGL nowadays...

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • D Offline
              D Offline
              davecotter
              wrote on last edited by
              #5

              I appreciate people chiming in offering suggestions of what else i can do, but that's not what i'm here for. Really i just want to know if this is the expected behavior: that calling drawImage() with SmoothPixmapTransform actually looks terrible.

              It's just a yes or no.

              Then if it's yes, the question is why, and if the answer is no, the question is what am i doing wrong...

              O 1 Reply Last reply
              0
              • D Offline
                D Offline
                davecotter
                wrote on last edited by
                #6

                nobody has seen this before?

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  davecotter
                  wrote on last edited by
                  #7

                  is there anyone who can confirm that this is a bug before i file it?

                  jsulmJ V 2 Replies Last reply
                  0
                  • D davecotter

                    is there anyone who can confirm that this is a bug before i file it?

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    @davecotter You should ask Qt developers on their mailing list

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • D davecotter

                      is there anyone who can confirm that this is a bug before i file it?

                      V Offline
                      V Offline
                      vladstelmahovsky
                      wrote on last edited by
                      #9

                      @davecotter noone using qpainter for video output, sorry
                      as an exercise, you can compare smoothing code in qimage and qpainter

                      1 Reply Last reply
                      0
                      • D davecotter

                        I appreciate people chiming in offering suggestions of what else i can do, but that's not what i'm here for. Really i just want to know if this is the expected behavior: that calling drawImage() with SmoothPixmapTransform actually looks terrible.

                        It's just a yes or no.

                        Then if it's yes, the question is why, and if the answer is no, the question is what am i doing wrong...

                        O Offline
                        O Offline
                        ollarch
                        wrote on last edited by
                        #10

                        @davecotter You say that you appreciate people offering suggestions but that's not what you are here.
                        Let me suggest you a thing, sometimes other people have better ideas than you. For example, I can suggest you to use a QGraphicsScene with a QGraphicsRectItem or a QGraphicsPixmapItem to play video at fast fps, but hey! If you still want to use a simple QPainter to do the job...
                        QGraphicsView also is capable of draw using OpenGL without learning OpenGL how to paint using OpenGL in a QWidget.
                        As I said, it is only a suggestion as I think/know that you will not advise play a 30fps video on a QWidget without high CPU usage.

                        1 Reply Last reply
                        1
                        • D Offline
                          D Offline
                          davecotter
                          wrote on last edited by
                          #11

                          got a reply on the mailing list:

                          Likes like you are downscaling more than 2x. QPainter is doing bilinear
                          sampling when smooth scaling, and that produces bad results at 2x downscaling.
                          QImage::smoothScaled() uses a slower box scaling algorithm that works at even
                          the most aggressive downscaling.

                          :D

                          1 Reply Last reply
                          1

                          • Login

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