2011-10-01 130 views
3

在基於PyQt的GUI程序中,我在調整大小後將幾個PNG文件繪製爲QPixmap。所以這裏基本上會發生什麼:抗鋸齒PNG在Qt中調整大小?

bitmap = QPixmap("foo.png") 
bitmap.scaleToHeight(38) # original is larger than this 
scene.addItem(QGraphicsPixmapItem(bitmap)) # Add to graphics scene 

問題是:之後,位圖相當醜陋。有沒有辦法以抗鋸齒的方式做到這一點?

回答

6

查看documentation

bitmap = bitmap.scaledToHeight(38, Qt.SmoothTransformation) 
+0

謝謝。它現在看起來很漂亮 - 可以更仔細地閱讀文檔。 – lang2