How to properly drawPixmap with smooth transformation
// 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 ?
250x250 -> 18x18
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.
I draw image in my own item delegate, in paint(...) function.
scale function is not a good solution, smooth effect is not so good.
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.
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.