【发布时间】:2015-09-18 22:25:44
【问题描述】:
我正在尝试制作一个小函数,该函数将获取已渲染为所需大小两倍的缩略图,并使用抗锯齿调整它的大小,以便生成漂亮的平滑缩略图。
这是我目前得到的:
from PySide import QtGui, QtCore
def resizeImage(image, outSize):
bitmap = QtGui.QPixmap(image)
bitmap.scaled(QtCore.QSize(outSize, outSize),aspectMode=QtCore.Qt.KeepAspectRatio, mode=QtCore.Qt.SmoothTransformation) # original is larger than this
print bitmap.size()
file = QtCore.QFile(image)
file.open(QtCore.QIODevice.WriteOnly)
bitmap.save(file)
file.close()
resizeImage("image.png", outSize = 256)
问题是当我调用 bitmap.scaled 时,像素图的大小似乎没有改变 - 我在这里遗漏了一些明显的东西吗?
【问题讨论】:
标签: python image qt user-interface pyside