本文整理汇总了Python中PySide.QtGui.QImage.load方法的典型用法代码示例。如果您正苦于以下问题:Python QImage.load方法的具体用法?Python QImage.load怎么用?Python QImage.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QImage
的用法示例。
在下文中一共展示了QImage.load方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_gl
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import load [as 别名]
def init_gl(self):
if self.is_initialized:
return
self.texture_id = glGenTextures(1)
glEnable(GL_TEXTURE_CUBE_MAP)
glBindTexture(GL_TEXTURE_CUBE_MAP, self.texture_id)
# Define all 6 faces
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)
if True:
img = QImage()
img.load("skybox/miramar_lf.tif")
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, img.width(), img.height(),
0, GL_RGBA, GL_UNSIGNED_BYTE, fname_to_tex("skybox/miramar_ft.tif"))
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA8, img.width(), img.height(),
0, GL_RGBA, GL_UNSIGNED_BYTE, fname_to_tex("skybox/miramar_bk.tif"))
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA8, img.width(), img.height(),
0, GL_RGBA, GL_UNSIGNED_BYTE, fname_to_tex("skybox/miramar_dn.tif"))
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, img.width(), img.height(),
0, GL_RGBA, GL_UNSIGNED_BYTE, fname_to_tex("skybox/miramar_up.tif"))
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA8, img.width(), img.height(),
0, GL_RGBA, GL_UNSIGNED_BYTE, fname_to_tex("skybox/miramar_rt.tif"))
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8, img.width(), img.height(),
0, GL_RGBA, GL_UNSIGNED_BYTE, fname_to_tex("skybox/miramar_lf.tif"))
else:
test_img = numpy.array(256 * [50,50,128,255], 'uint8')
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, test_img)
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, test_img)
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, test_img)
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, test_img)
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, test_img)
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, test_img)
glDisable(GL_TEXTURE_CUBE_MAP)
self.shader.init_gl()
self.is_initialized = True
示例2: requestImage
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import load [as 别名]
def requestImage(self, id, size, requestedSize):
key = (id, requestedSize)
if key in self._cache:
return self._cache[key]
cover_file, cover_url, podcast_url, podcast_title = id.split('|')
def get_filename():
return self.downloader.get_cover(cover_file, cover_url,
podcast_url, podcast_title, None, None, True)
filename = get_filename()
image = QImage()
if not image.load(filename):
if filename.startswith(cover_file):
logger.info('Deleting broken cover art: %s', filename)
util.delete_file(filename)
image.load(get_filename())
if not image.isNull():
self._cache[key] = image.scaled(requestedSize,
Qt.KeepAspectRatioByExpanding,
Qt.SmoothTransformation)
return self._cache[key]
示例3: __loadCrop
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import load [as 别名]
def __loadCrop(self, loadCrop=True):
name_wo_ext = self.__fileNameWoExt()
json_data = open(name_wo_ext + '.json').read()
image = QImage()
if loadCrop:
image.load(name_wo_ext + '.crop', 'PNG')
return image, json.loads(json_data)
示例4: ImageMediaView
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import load [as 别名]
class ImageMediaView(MediaView):
def __init__(self, media, parent):
super(ImageMediaView, self).__init__(media, parent)
self._widget = QLabel(parent)
self._widget.setGeometry(media['_geometry'])
self._img = QImage()
self.set_default_widget_prop()
@Slot()
def play(self):
self._finished = 0
path = "%s/%s" % (self._save_dir, self._options['uri'])
rect = self._widget.geometry()
self._img.load(path)
self._img = self._img.scaled(rect.width(), rect.height(),
Qt.IgnoreAspectRatio, Qt.SmoothTransformation)
self._widget.setPixmap(QPixmap.fromImage(self._img))
self._widget.show()
self._widget.raise_()
self._play_timer.setInterval(int(float(self._duration) * 1000))
self._play_timer.start()
self.started_signal.emit()
示例5: fname_to_tex
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import load [as 别名]
def fname_to_tex(file_name):
img = QImage()
img.load(file_name)
img2 = QGLWidget.convertToGLFormat(img)
img3 = str(img2.bits())
return img3
示例6: ImageBase
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import load [as 别名]
class ImageBase(QLabel):
def __init__(self, *args, **kwargs):
self.transInfo = ImageBaseTranslateInfo()
super(ImageBase, self).__init__(*args, **kwargs)
self.installEventFilter(self)
self.image = QImage()
self.pixmap = QPixmap()
self.label = QLabel(self)
self.imagePath = ""
self.aspect = 1
self.imageClean = True
def clearImage(self):
self.label.clear()
self.imageClean = True
def loadImage(self, filePath ):
self.imageClean = False
if self.imagePath == filePath: return None
self.imagePath = filePath
self.aspect = 1
if self.image.load(filePath): pass
self.transInfo.setDefault()
widgetSize = min( self.parentWidget().width(), self.parentWidget().height() ) * 0.9
imageWidth = self.image.width()
self.transInfo.scale = widgetSize / float( imageWidth )
self.resize()
def resize(self):
if self.imageClean: return None
trValue = QTransform().scale( self.transInfo.scaleX(), self.transInfo.scaleY() )
trValue *= QTransform().rotate( self.transInfo.rotValue )
imageTransformed = self.image.transformed(trValue)
imageWidth = imageTransformed.width()
imageHeight = imageTransformed.height()
self.pixmap = QPixmap.fromImage( imageTransformed )
self.label.setPixmap( self.pixmap )
marginLeft = (self.width() - imageWidth)/2.0
marginTop = (self.height() - imageHeight)/2.0
self.label.setGeometry( marginLeft + self.transInfo.x,marginTop + self.transInfo.y, imageWidth, imageHeight )
self.label.paintEvent(QPaintEvent(QtCore.QRect( 0,0,self.width(), self.height() )))
def flip(self, pressX ):
offsetX = pressX - self.width()/2
self.transInfo.rotValue *= -1
self.transInfo.x = (self.transInfo.x - offsetX)*-1 + offsetX
self.transInfo.scaleMultX *= -1
self.resize()
def show( self ):
self.label.show()
def eventFilter( self, Obj, event ):
if event.type() == QtCore.QEvent.Resize:
self.resize()
elif event.type() == QtCore.QEvent.MouseButtonPress:
pressX = event.x()-self.width()/2
pressY = event.y()-self.height()/2
self.transInfo.buttonPress(event.button(), pressX, pressY )
elif event.type() == QtCore.QEvent.MouseButtonRelease:
if self.transInfo.x == self.transInfo.bx and self.transInfo.y == self.transInfo.by:
pass
self.transInfo.buttonRelease()
Window_global.saveInfo()
elif event.type() == QtCore.QEvent.MouseMove:
pressX = event.x()-self.width()/2
pressY = event.y()-self.height()/2
self.transInfo.drag( pressX, pressY )
self.resize()
elif event.type() == QtCore.QEvent.MouseButtonDblClick:
self.flip( event.x() )
elif event.type() == QtCore.QEvent.Wheel:
pressX = event.x()-self.width()/2
pressY = event.y()-self.height()/2
#.........这里部分代码省略.........
示例7: __init__
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import load [as 别名]
class UpngGui:
def __init__(self):
self.ui = None
self.image = None
def main(self, argv=None):
if argv is None:
argv = sys.argv
self.app = QApplication(argv)
loader = QUiLoader()
self.ui = loader.load('./upng.ui')
self.ui.openButton.clicked.connect(self.openImage)
self.ui.resizeButton.clicked.connect(self.resizeImage)
self.ui.saveButton.clicked.connect(self.saveImage)
self.ui.show()
return self.app.exec_()
def openImage(self):
fileName = QFileDialog.getOpenFileName(self.ui,
tr("Open Image"), "./",
tr("Image Files (*.png *.jpg *.bmp *.ppm)"))
if fileName:
fileName = fileName[0]
self.image = QImage()
self.image.load(fileName)
w = self.image.width()
h = self.image.height()
self.ui.spinBoxWidth.setValue(w)
self.ui.spinBoxHeight.setValue(h)
self.resizeImage()
def resizeImage(self):
if not self.image:
self.ui.scrollArea.takeWidget()
return
w = self.ui.spinBoxWidth.value()
h = self.ui.spinBoxHeight.value()
img = self.image.scaled(w,h)
pix = QPixmap.fromImage(img)
lbl = QLabel()
lbl.setPixmap(pix)
self.ui.scrollArea.takeWidget()
self.ui.scrollArea.setWidget(lbl)
def saveImage(self):
if not self.image:
return
w = self.ui.spinBoxWidth.value()
h = self.ui.spinBoxHeight.value()
img = self.image.scaled(w,h).convertToFormat(QImage.Format_ARGB32)
fileName = QFileDialog.getSaveFileName(self.ui,
tr("Save Simple Png Image"), "./",
tr("Image Files (*.png *.ppm)"))
if fileName:
fileName = fileName[0]
self.app.setOverrideCursor(QCursor(Qt.WaitCursor))
self.ui.setEnabled(False)
if fileName.endswith('ppm'):
writePpm(fileName, img)
if fileName.endswith('png'):
writeSPangImage(fileName, img, self.app)
else:
writeSPangImage(fileName + ".png", img, self.app)
self.ui.setEnabled(True)
self.app.restoreOverrideCursor()
示例8: _loadImage
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import load [as 别名]
def _loadImage(self, path):
image = QImage()
if not image.load(path):
raise ImageLoadError(path)
else:
return image
示例9: fname_to_qimage
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import load [as 别名]
def fname_to_qimage(file_name):
this_dir, this_filename = os.path.split(__file__)
fn = os.path.join(this_dir, "skybox", file_name)
img = QImage()
img.load(fn)
return img