Scaled QPixmap looks bad

邮差的信 提交于 2019-12-07 09:10:05

问题


I have the following widget:

pixmap = QtGui.QPixmap(r'pics\cdaudio.png').scaled(100, 100)

The image is scaled down, from 256x256. It looks pretty choppy:

How can I scale it smoothly from within Qt?


回答1:


Use the transformMode parameter:

pixmap = QtGui.QPixmap(r'pics\cdaudio.png').scaled(100, 100, transformMode=QtCore.Qt.SmoothTransformation)



回答2:


According to @iTayb, here's what I came up with:

// Scale the source to the requested size with 
//  the KeepAspectRatio as aspectMode & SmoothTransformation as mode
*source = source->scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
target->setPixmap(*source);



回答3:


Why not using the SVG format (and the Qt SVG module for this) if possible ?



来源:https://stackoverflow.com/questions/13891142/scaled-qpixmap-looks-bad

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!