QPainter::drawImage() is terrible at smooth scaling?
-
when i use
drawImage()
to do scaling, even having setSmoothPixmapTransform
rendering hint, it, well, really sucks. like here look:
I saw this article that suggests this is expected, and instead I should be usingQImage::smoothScaled()
to produce the scaled image first, THEN blit with drawImage. Well, yes, the results are as I expected in the first place:
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 theQImage
or some other render hint i haven't seen? -
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
-
@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.
-
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()
withSmoothPixmapTransform
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?
-
@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