本文整理匯總了Python中PySide2.QtGui.QImage方法的典型用法代碼示例。如果您正苦於以下問題:Python QtGui.QImage方法的具體用法?Python QtGui.QImage怎麽用?Python QtGui.QImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PySide2.QtGui
的用法示例。
在下文中一共展示了QtGui.QImage方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _get_application_icon
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QImage [as 別名]
def _get_application_icon() -> QIcon:
"""
This finds the running blender process, extracts the blender icon from the blender.exe file on disk and saves it to the user's temp folder.
It then creates a QIcon with that data and returns it.
Returns QIcon: Application Icon
"""
icon_filepath = Path(__file__).parent / ".." / "blender_icon_16.png"
icon = QIcon()
if icon_filepath.exists():
image = QImage(str(icon_filepath))
if not image.isNull():
icon = QIcon(QPixmap().fromImage(image))
return icon
示例2: handleNetworkData
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QImage [as 別名]
def handleNetworkData(self, reply):
img = QImage()
tp = Point(reply.request().attribute(QNetworkRequest.User))
url = reply.url()
if not reply.error():
if img.load(reply, None):
self._tilePixmaps[tp] = QPixmap.fromImage(img)
reply.deleteLater()
self.updated.emit(self.tileRect(tp))
# purge unused tiles
bound = self._tilesRect.adjusted(-2, -2, 2, 2)
for tp in list(self._tilePixmaps.keys()):
if not bound.contains(tp):
del self._tilePixmaps[tp]
self.download()
示例3: __init__
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QImage [as 別名]
def __init__(self, image = QtGui.QImage(), x = 0, y = 0, width = 0, height = 0):
super(BitmapData, self).__init__()
if isinstance(image, QtGui.QImage):
if stage.app:
image = QtGui.QPixmap(image)
elif not isinstance(image, QtGui.QPixmap):
raise TypeError("BitmapData(image = QtGui.QImage(), x = 0, y = 0, width = 0, height = 0): parameter 'image' must be a QPixmap or QImage object.")
self.image = image
self.x = x
self.y = y
self.width = width
self.height = height
self.__locked = False
self.__pixelData = []
if image is not None:
if width == 0:
self.width = image.width()
if height == 0:
self.height = image.height()
示例4: get_icon
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QImage [as 別名]
def get_icon(icon, size=24):
"""get svg icon from icon resources folder as a pixel map
"""
img = get_icon_path("{}.svg".format(icon))
svg_renderer = QtSvg.QSvgRenderer(img)
image = QtGui.QImage(size, size, QtGui.QImage.Format_ARGB32)
# Set the ARGB to 0 to prevent rendering artifacts
image.fill(0x00000000)
svg_renderer.render(QtGui.QPainter(image))
pixmap = QtGui.QPixmap.fromImage(image)
return pixmap
示例5: _image_to_clipboard
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QImage [as 別名]
def _image_to_clipboard(path):
"""Copies the image at path to the system's global clipboard."""
if _in_standalone():
raise Exception("Cannot copy to clipboard from Maya Standalone")
image = QtGui.QImage(path)
clipboard = QtWidgets.QApplication.clipboard()
clipboard.setImage(image, mode=QtGui.QClipboard.Clipboard)
示例6: setBackgroundImage
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QImage [as 別名]
def setBackgroundImage(self, image):
screen = getScreenGeometry()
pixmap = QPixmap(QImage(image)).scaled(screen.width(), screen.height(), Qt.KeepAspectRatioByExpanding)
self.label.setPixmap(pixmap)
self.label.setGeometry(0, 0, screen.width(), self.label.sizeHint().height())
示例7: _show_legend
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QImage [as 別名]
def _show_legend(self):
pen = QPen(Qt.transparent)
gradient = self._make_legend_gradient(self.LEGEND_X, self.LEGEND_Y,
self.LEGEND_X, self.LEGEND_Y + self.legend_height)
brush = QBrush(gradient)
self.legend = self.scene.addRect(self.LEGEND_X, self.LEGEND_Y,
self.LEGEND_WIDTH, self.legend_height, pen, brush)
reference_gradient = self._make_legend_gradient(0, 0, self.LEGEND_WIDTH, 1000)
base_img = QImage(self.LEGEND_WIDTH, 1000, QImage.Format.Format_ARGB32)
p = QPainter(base_img)
p.fillRect(base_img.rect(),reference_gradient)
self.legend_img = base_img #reference shade
示例8: _loopDraw
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QImage [as 別名]
def _loopDraw(self, c):
bmpd = self.bitmapData
image = bmpd.image
if isinstance(image, QtGui.QPixmap):
c.drawPixmap(0, 0, image, bmpd.x, bmpd.y, bmpd.width, bmpd.height)
elif isinstance(image, QtGui.QImage):
c.drawImage(0, 0, image, bmpd.x, bmpd.y, bmpd.width, bmpd.height)
示例9: doLoad
# 需要導入模塊: from PySide2 import QtGui [as 別名]
# 或者: from PySide2.QtGui import QImage [as 別名]
def doLoad(self):
image = QtGui.QImage()
image.load(self.path)
self.resultReady.emit(image)