Python PySide2.QtGui.QImage() Examples

The following are 11 code examples of PySide2.QtGui.QImage(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PySide2.QtGui , or try the search function .
Example #1
Source File: blender_application.py    From bqt with Mozilla Public License 2.0 6 votes vote down vote up
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 
Example #2
Source File: lightmap.py    From GridCal with GNU General Public License v3.0 6 votes vote down vote up
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() 
Example #3
Source File: display.py    From pylash_engine with MIT License 6 votes vote down vote up
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() 
Example #4
Source File: pyqt.py    From mgear_core with MIT License 5 votes vote down vote up
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 
Example #5
Source File: capture.py    From pyblish-bumpybox with GNU Lesser General Public License v3.0 5 votes vote down vote up
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) 
Example #6
Source File: capture.py    From maya-capture with MIT License 5 votes vote down vote up
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) 
Example #7
Source File: Widgets.py    From Jade-Application-Kit with GNU General Public License v3.0 5 votes vote down vote up
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()) 
Example #8
Source File: Widgets.py    From Jade-Application-Kit with GNU General Public License v3.0 5 votes vote down vote up
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()) 
Example #9
Source File: qtrace_viewer.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 
Example #10
Source File: display.py    From pylash_engine with MIT License 5 votes vote down vote up
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) 
Example #11
Source File: loaders.py    From pylash_engine with MIT License 5 votes vote down vote up
def doLoad(self):
			image = QtGui.QImage()
			image.load(self.path)
			self.resultReady.emit(image)