我希望使用QtCreator和Python构建一个mipmapping程序。到目前为止,我的应用程序如下所示:
在这里你可以上传一个图像到程序,它将显示你的原始图像在左标签框。按“创建mipmap”时,它应该会在右侧标签框中显示mipmap。在
下一个部分是我被卡住的地方。在Python中有mipmapping算法可以使用吗?我看到这个question on StackOverflow有点帮助,但是我不能安装numpy,因为它不能识别我的python3.4,尽管它已经安装了。在
以下是我目前所掌握的:
from __future__ import division
from PyQt4 import QtCore, QtGui, QtOpenGL
from PyQt4.QtGui import * #Used to import QPixmap. DO NOT REMOVE.
from PyQt4.QtCore import * #Used to import Qt.KeepAspectRation. DO NOT REMOVE.
import sys, os
import mmCreator
class MyApp(QtGui.QMainWindow, mmCreator.Ui_MainWindow):
def __init__(self, parent=None):
super(MyApp, self).__init__(parent)
self.setupUi(self)
self.btnSelect.clicked.connect(self.select_image)
self.btnConvert.clicked.connect(self.mipmap)
#self.btnDownload.clicked.connect(self.download)
def select_image(self):
self.origImage.clear()
image = QtGui.QFileDialog.getOpenFileName(self,
"Select Image",
"",
"Image File (*.jpg *.png *.gif)")
pixmap = QPixmap(image)
scaledPixmap = pixmap.scaled(self.origImage.size(), Qt.KeepAspectRatio)
self.origImage.setPixmap(scaledPixmap)
self.origImage.show()
#def mipmap():
那么,除了numpy之外,有没有其他方法可以在我的程序中实现mipmap呢?在
感谢任何帮助。在
您可以使用QPixmap.scaled创建半宽或半高的图像。在
相关问题 更多 >
编程相关推荐