PDA

View Full Version : Resizing a pixmap without losing quality



Grzyboo
4th August 2015, 12:25
I want to resize a pixmap and not lose the quality of image. If you make something bigger than the source size is, it will obviously lose quality, no doubt.
However, what I want to do is resize like that:
100% -> 25% -> 100%
Using QPixmap.scaled unfortunately loses the quality and the final image looks terrible, even though it's the exact same size it was when loaded.
Can I make it somehow else rather than saving file's path and loading pixmap from file every time I enlarge it after making it smaller?

yeye_olive
4th August 2015, 13:06
Keep two QPixmap instances around: a scaled one that you display, and the original one from which you recompute each scaled version.

anda_skoa
4th August 2015, 13:07
Just keep the original image.

scaled() doesn't affect the image it is being called on, it returns the scaled version as a new image.

Cheers,
_

Grzyboo
4th August 2015, 13:27
I'm resizing QLabel widget's image. Seems like I need to save an original image for every widget.