How to properly drawPixmap with smooth transformation
-
code :
// draw table cell painter->setRenderHint(QPainter::Antialiasing, true); painter->setRenderHint(QPainter::SmoothPixmapTransform, true); QPixmap pm(":/icons/xxx.png"); ... ... painter->drawPixmap(iconrect, pm);
The size of file xxx.png is 250x250. The table cell size is 24x24. But the image qt drawed still have no antialias effect.
-
How big is the original image ?
-
@Manifolds
Hi
You can use the scaled function to scale your self .
QPixmap B2=orgpic.scaled(18,18, Qt::KeepAspectRatio,Qt::SmoothTransformation);
If you have many cells, its recommended do scale only once and use the scaled copy for drawing as not
to perform the expensive operation each repaint. -
Hi,
At the same time you are reducing to 18 pixels, this isn't much. You can't expect to have at that size something as smooth as with a picture that's about 15 times bigger.
-
@Manifolds
Qt does quite good actually with scaled.
photoshop did not produce anything better.
That is with algorithm they have perfected over a decade.
The PNG is not vector and you kill most of it scaling that much.
To use icons of such varying size. The common solution is to hand correct scaled version from
ei photoshop for the various sizes.