Qt中如何对PNG进行抗锯齿缩放?

6 投票
1 回答
3248 浏览
提问于 2025-04-17 03:30

在一个基于PyQt的图形界面程序中,我在调整大小后绘制了一些PNG文件作为QPixmap。基本上,事情是这样的:

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

问题是:之后,图像看起来很糟糕。有办法让这个过程变得更平滑吗?

1 个回答

11

请查看文档

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

撰写回答