當前位置: 首頁>>代碼示例>>Python>>正文


Python QtGui.QImage方法代碼示例

本文整理匯總了Python中PyQt5.QtGui.QImage方法的典型用法代碼示例。如果您正苦於以下問題:Python QtGui.QImage方法的具體用法?Python QtGui.QImage怎麽用?Python QtGui.QImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtGui的用法示例。


在下文中一共展示了QtGui.QImage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QImage [as 別名]
def __init__(self, output_controller: "PrinterOutputController", key: str = "", name: str = "", parent = None) -> None:
        super().__init__(parent)
        self._output_controller = output_controller
        self._state = ""
        self._time_total = 0
        self._time_elapsed = 0
        self._name = name  # Human readable name
        self._key = key  # Unique identifier
        self._assigned_printer = None  # type: Optional[PrinterOutputModel]
        self._owner = ""  # Who started/owns the print job?

        self._configuration = None  # type: Optional[PrinterConfigurationModel]
        self._compatible_machine_families = []  # type: List[str]
        self._preview_image_id = 0

        self._preview_image = None  # type: Optional[QImage] 
開發者ID:Ultimaker,項目名稱:Cura,代碼行數:18,代碼來源:PrintJobOutputModel.py

示例2: resize_image

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QImage [as 別名]
def resize_image(cover_image_raw):
    if isinstance(cover_image_raw, QtGui.QImage):
        cover_image = cover_image_raw
    else:
        cover_image = QtGui.QImage()
        cover_image.loadFromData(cover_image_raw)

    # Resize image to what literally everyone
    # agrees is an acceptable cover size
    cover_image = cover_image.scaled(
        420, 600, QtCore.Qt.IgnoreAspectRatio)

    byte_array = QtCore.QByteArray()
    buffer = QtCore.QBuffer(byte_array)
    buffer.open(QtCore.QIODevice.WriteOnly)
    cover_image.save(buffer, 'jpg', 75)

    cover_image_final = io.BytesIO(byte_array)
    cover_image_final.seek(0)
    return cover_image_final.getvalue() 
開發者ID:BasioMeusPuga,項目名稱:Lector,代碼行數:22,代碼來源:sorter.py

示例3: paintEvent

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QImage [as 別名]
def paintEvent(self, event):
        painter = QPainter()
        painter.begin(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.fillRect(event.rect(), QBrush(QColor(255, 255, 255, 200)))
        painter.setPen(QPen(Qt.NoPen))

        if self.lists is not None:
            path = os.path.abspath(os.path.dirname(__file__)) + '/static/'
            path += self.lists[self.list_index] + '.png'
            self.list_index += 1
            if self.list_index >= len(self.lists):
                self.list_index = 0
            image = QImage(path)
            rect_image = image.rect()
            rect_painter = event.rect()
            dx = (rect_painter.width() - rect_image.width()) / 2.0
            dy = (rect_painter.height() - rect_image.height()) / 2.0
            painter.drawImage(dx, dy, image)

        painter.end() 
開發者ID:canard0328,項目名稱:malss,代碼行數:23,代碼來源:waiting_animation.py

示例4: __init__

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QImage [as 別名]
def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

        self._stream_buffer = QByteArray()
        self._stream_buffer_start_index = -1
        self._network_manager = None  # type: QNetworkAccessManager
        self._image_request = None  # type: QNetworkRequest
        self._image_reply = None  # type: QNetworkReply
        self._image = QImage()
        self._image_rect = QRect()

        self._source_url = QUrl()
        self._started = False

        self._mirror = False

        self.setAntialiasing(True) 
開發者ID:Ultimaker,項目名稱:Cura,代碼行數:19,代碼來源:NetworkMJPGImage.py

示例5: requestImage

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QImage [as 別名]
def requestImage(self, id: str, size: QSize) -> Tuple[QImage, QSize]:
        """Request a new image.

        :param id: id of the requested image
        :param size: is not used defaults to QSize(15, 15)
        :return: an tuple containing the image and size
        """

        # The id will have an uuid and an increment separated by a slash. As we don't care about the value of the
        # increment, we need to strip that first.
        uuid = id[id.find("/") + 1:]
        for output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices():
            if not hasattr(output_device, "printJobs"):
                continue

            for print_job in output_device.printJobs:
                if print_job.key == uuid:
                    if print_job.getPreviewImage():
                        return print_job.getPreviewImage(), QSize(15, 15)

                    return QImage(), QSize(15, 15)
        return QImage(), QSize(15, 15) 
開發者ID:Ultimaker,項目名稱:Cura,代碼行數:24,代碼來源:PrintJobPreviewImageProvider.py

示例6: preRead

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QImage [as 別名]
def preRead(self, file_name, *args, **kwargs):
        img = QImage(file_name)

        if img.isNull():
            Logger.log("e", "Image is corrupt.")
            return MeshReader.PreReadResult.failed

        width = img.width()
        depth = img.height()

        largest = max(width, depth)
        width = width / largest * self._ui.default_width
        depth = depth / largest * self._ui.default_depth

        self._ui.setWidthAndDepth(width, depth)
        self._ui.showConfigUI()
        self._ui.waitForUIToClose()

        if self._ui.getCancelled():
            return MeshReader.PreReadResult.cancelled
        return MeshReader.PreReadResult.accepted 
開發者ID:Ultimaker,項目名稱:Cura,代碼行數:23,代碼來源:ImageReader.py

示例7: insertImage

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QImage [as 別名]
def insertImage(self):

        # Get image file name
        filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Insert image',".","Images (*.png *.xpm *.jpg *.bmp *.gif)")

        if filename:
            
            # Create image object
            image = QtGui.QImage(filename)

            # Error if unloadable
            if image.isNull():

                popup = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical,
                                          "Image load error",
                                          "Could not load image file!",
                                          QtWidgets.QMessageBox.Ok,
                                          self)
                popup.show()

            else:

                cursor = self.text.textCursor()

                cursor.insertImage(image,filename) 
開發者ID:goldsborough,項目名稱:Writer-Tutorial,代碼行數:27,代碼來源:part-3.py

示例8: _slotMapUpdate

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QImage [as 別名]
def _slotMapUpdate(self):
        #self.mapCoords.init( 
        #        self._mapUpdate.nw[0], self._mapUpdate.nw[1],
        #        self._mapUpdate.ne[0], self._mapUpdate.ne[1],
        #        self._mapUpdate.sw[0], self._mapUpdate.sw[1],
        #        self.mapItem.MAP_NWX, self.mapItem.MAP_NWY, 
        #        self.mapItem.MAP_NEX, self.mapItem.MAP_NEY, 
        #        self.mapItem.MAP_SWX, self.mapItem.MAP_SWY )
        image = QtGui.QImage(self._mapUpdate.pixels, self._mapUpdate.width, self._mapUpdate.height, QtGui.QImage.Format_Indexed8)
        image.setColorTable(self.COLORTABLE)
        self.playerMarker.setMapPos(self._mapUpdate.width/2, self._mapUpdate.height/2, self.playerMarker.mapPosR, False)
        if self.mapItem:
            self.mapItem._setMapPixmap(QtGui.QPixmap.fromImage(image))
        if self.mapEnabledFlag:
            self.playerMarker.setVisible(True)
        else:
            self.playerMarker.setVisible(False) 
開發者ID:matzman666,項目名稱:PyPipboyApp,代碼行數:19,代碼來源:localmapwidget.py

示例9: __init__

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QImage [as 別名]
def __init__(self,parent="None",title="None",description="None",url="None",urlImage="None"):
        super(Tiles,self).__init__()
        #Heading Widget
        self.heading = QLabel('<b>%s</b>'%title)
        #SubHeading Widget with link to open in browser
        self.subHeading = QLabel('{}<a href="{}">...more</a>'.format(description,url))
        self.subHeading.setOpenExternalLinks(True)
        #Image Widget with article
        try:
            data = urllib.request.urlopen(urlImage).read()
        except:
            data = urllib.request.urlopen("https://ibb.co/XY30sjs").read()
        self.image = QImage()
        self.image.loadFromData(data)
        self.imageLabel = QLabel("image")
        self.imageLabel.setPixmap(QPixmap(self.image).scaled(64,64,Qt.KeepAspectRatio))
        self.tileLayout = QGridLayout()
        self.tileLayout.addWidget(self.heading,1,0)
        self.tileLayout.addWidget(self.imageLabel,1,1)
        self.tileLayout.addWidget(self.subHeading,2,0) 
開發者ID:ugroot,項目名稱:GROOT,代碼行數:22,代碼來源:newsWindow.py

示例10: genQrcode

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QImage [as 別名]
def genQrcode(self):
		content = self.content_edit.text()
		try:
			margin = int(self.margin_spinbox.text())
		except:
			margin = 0
		size = int(self.size_combobox.currentText().split('*')[0])
		qr = qrcode.QRCode(version=1,
						   error_correction=qrcode.constants.ERROR_CORRECT_L,
						   box_size=size//29,
						   border=margin)
		qr.add_data(content)
		self.qr_img = qr.make_image()
		fp = io.BytesIO()
		self.qr_img.save(fp, 'BMP')
		qimg = QtGui.QImage()
		qimg.loadFromData(fp.getvalue(), 'BMP')
		qimg_pixmap = QtGui.QPixmap.fromImage(qimg)
		self.show_label.setPixmap(qimg_pixmap) 
開發者ID:CharlesPikachu,項目名稱:Tools,代碼行數:21,代碼來源:genQrcode.py

示例11: paintEvent

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QImage [as 別名]
def paintEvent(self, event):
        if self.count():
            QtWidgets.QTabWidget.paintEvent(self, event)
        else:
            painter = QtGui.QPainter(self)
            rect = event.rect()
            image = QtGui.QImage("images/pychemqt.png")
            rectImage = QtCore.QRect(25, rect.center().y()-50, 100, 100)
            painter.drawImage(rectImage, image)
            txt = QtWidgets.QApplication.translate(
                "pychemqt", """Welcome to pychemqt,
a software for simulating Chemical Engineering units operations,

Copyright © 2012 Juan José Gómez Romera (jjgomera)
Licenced with GPL.v3
This software is distributed in the hope that it will be useful,
but without any warranty, it is provided "as is" without warranty of any kind

You can start by creating a new project or opening an existing project.""",
                None)
            rect.setLeft(150)
            painter.drawText(rect, QtCore.Qt.AlignVCenter, txt) 
開發者ID:jjgomera,項目名稱:pychemqt,代碼行數:24,代碼來源:mainWindow.py

示例12: savePFDImage

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QImage [as 別名]
def savePFDImage(self):
        if self.filename[self.idTab]:
            dir = os.path.dirname(str(self.filename[self.idTab]))
        else:
            dir = "."
        fname = QtWidgets.QFileDialog.getSaveFileName(
            None,
            QtWidgets.QApplication.translate("pychemqt", "Save PFD as image"),
            dir, "Portable Network Graphics (*.png)")[0]
        if fname:
            rect = self.currentScene.sceneRect()
            img = QtGui.QImage(
                rect.width(), rect.height(),
                QtGui.QImage.Format_ARGB32_Premultiplied)
            p = QtGui.QPainter(img)
            self.currentScene.render(p)
            p.end()
            img.save(fname) 
開發者ID:jjgomera,項目名稱:pychemqt,代碼行數:20,代碼來源:mainWindow.py

示例13: GetImg

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QImage [as 別名]
def GetImg(imgname, image=False):
    """
    Returns the image path from the PNG filename imgname
    """
    imgname = str(imgname)

    # Try to find the best path
    path = 'miyamotodata/sprites/' + imgname

    for folder in reversed(SpritesFolders): # find the most recent copy
        tryPath = folder + '/' + imgname
        if os.path.isfile(tryPath):
            path = tryPath
            break

    # Return the appropriate object
    if os.path.isfile(path):
        if image: return QtGui.QImage(path)
        else: return QtGui.QPixmap(path) 
開發者ID:aboood40091,項目名稱:Miyamoto,代碼行數:21,代碼來源:spritelib.py

示例14: setGridSize

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QImage [as 別名]
def setGridSize(self, size):
        """
        Sets the grid size.
        """
        action = self.session.action('toggle_grid')
        size = clamp(size, 0)
        if size <= 0 or not action.isChecked():
            brush = QtGui.QBrush(QtCore.Qt.NoBrush)
        else:
            image = QtGui.QImage(size, size, QtGui.QImage.Format_RGB32)
            image.fill(QtCore.Qt.white)
            painter = QtGui.QPainter(image)
            painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(80, 80, 80, 255)), 1, QtCore.Qt.SolidLine))
            painter.drawPoint(QtCore.QPointF(0, 0))
            painter.end()
            brush = QtGui.QBrush(image)
        self.setBackgroundBrush(brush) 
開發者ID:danielepantaleone,項目名稱:eddy,代碼行數:19,代碼來源:view.py

示例15: show_cover

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QImage [as 別名]
def show_cover(self, cover, cover_uid, as_background=False):
        cover = Media(cover, MediaType.image)
        url = cover.url
        app = self._app
        content = await app.img_mgr.get(url, cover_uid)
        img = QImage()
        img.loadFromData(content)
        pixmap = QPixmap(img)
        if not pixmap.isNull():
            if as_background:
                self.meta_widget.set_cover_pixmap(None)
                self._app.ui.right_panel.show_background_image(pixmap)
            else:
                self._app.ui.right_panel.show_background_image(None)
                self.meta_widget.set_cover_pixmap(pixmap)
            self._app.ui.table_container.updateGeometry() 
開發者ID:feeluown,項目名稱:FeelUOwn,代碼行數:18,代碼來源:table.py


注:本文中的PyQt5.QtGui.QImage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。