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



  • 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?


  • Qt Champions 2018

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



  • 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.


  • Qt Champions 2018

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



  • 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...



  • nobody has seen this before?



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


  • Qt Champions 2018

    @davecotter You should ask Qt developers on their mailing list



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



  • @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.



  • 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


Log in to reply
 

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