当前位置: 首页>>代码示例>>Python>>正文


Python QPainter.drawImage方法代码示例

本文整理汇总了Python中PySide.QtGui.QPainter.drawImage方法的典型用法代码示例。如果您正苦于以下问题:Python QPainter.drawImage方法的具体用法?Python QPainter.drawImage怎么用?Python QPainter.drawImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtGui.QPainter的用法示例。


在下文中一共展示了QPainter.drawImage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: drawIconWithShadow

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawImage [as 别名]
    def drawIconWithShadow(icon, rect, p, iconMode, radius, color, offset):
        cache = QPixmap()
        pixmapName = "icon {0} {1} {2}".format(icon.cacheKey(), iconMode, rect.height())

        if not QPixmapCache.find(pixmapName, cache):
            px = icon.pixmap(rect.size())
            cache = QPixmap(px.size() + QSize(radius * 2, radius * 2))
            cache.fill(Qt.transparent)

            cachePainter = QPainter(cache)
            if iconMode == QIcon.Disabled:
                im = px.toImage().convertToFormat(QImage.Format_ARGB32)
                for y in range(im.height()):
                    scanLine = im.scanLine(y)
                    for x in range(im.width()):
                        pixel = scanLine
                        intensity = qGray(pixel)
                        scanLine = qRgba(intensity, intensity, intensity, qAlpha(pixel))
                        scanLine += 1
                px = QPixmap.fromImage(im)

            # Draw shadow
            tmp = QImage(px.size() + QSize(radius * 2, radius * 2 + 1), QImage.Format_ARGB32_Premultiplied)
            tmp.fill(Qt.transparent)

            tmpPainter = QPainter(tmp)
            tmpPainter.setCompositionMode(QPainter.CompositionMode_Source)
            tmpPainter.drawPixmap(QPoint(radius, radius), px)
            tmpPainter.end()

            # blur the alpha channel
            blurred = QImage(tmp.size(), QImage.Format_ARGB32_Premultiplied)
            blurred.fill(Qt.transparent)
            blurPainter = QPainter(blurred)
            # todo : blur image
            blurPainter.end()

            tmp = blurred

            # blacken the image
            tmpPainter.begin(tmp)
            tmpPainter.setCompositionMode(QPainter.CompositionMode_SourceIn)
            tmpPainter.fillRect(tmp.rect(), color)
            tmpPainter.end()

            tmpPainter.begin(tmp)
            tmpPainter.setCompositionMode(QPainter.CompositionMode_SourceIn)
            tmpPainter.fillRect(tmp.rect(), color)
            tmpPainter.end()

            # draw the blurred drop shadow...
            cachePainter.drawImage(QRect(0, 0, cache.rect().width(), cache.rect().height()), tmp)

            # Draw the actual pixmap...
            cachePainter.drawPixmap(QPoint(radius, radius) + offset, px)
            QPixmapCache.insert(pixmapName, cache)

        targetRect = cache.rect()
        targetRect.moveCenter(rect.center())
        p.drawPixmap(targetRect.topLeft() - offset, cache)
开发者ID:nichollyn,项目名称:libspark,代码行数:62,代码来源:stylehelper.py

示例2: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawImage [as 别名]
    def paintEvent(self, e):
        'Custom Paint Event'
        p = QPainter(self)
        
        opt = QStyleOptionFrameV3()
        opt.initFrom(self)
        opt.rect = self.contentsRect()
        opt.lineWidth = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth, opt, self)
        opt.midLineWidth = 0
        opt.state = opt.state | QStyle.State_Sunken
        
        if self._active:
            opt.state = opt.state | QStyle.State_HasFocus
        else:
            opt.state = opt.state & ~QStyle.State_HasFocus;
        
        self.style().drawPrimitive(QStyle.PE_PanelLineEdit, opt, p)

        y = (opt.rect.height() - self._star.height()) / 2 
        width = self._star.width()
        
        for i in range(0, 5):
            x = i*(width + 1) + opt.lineWidth
            
            if self._rating >= i+0.5:
                p.drawImage(x, y, self._star if not self._active else self._blue)
            else:
                p.drawImage(x, y, self._dot)
开发者ID:asymworks,项目名称:python-divelog,代码行数:30,代码来源:controls.py

示例3: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawImage [as 别名]
 def paintEvent(self, paintEvent):
     painter = QPainter(self)
     painter.setRenderHint(QPainter.Antialiasing)
     painter.scale(self.scale, self.scale)
     painter.drawRect(0, 0, 511, 511)
     painter.drawImage(0, 0, self.image)
     if self.freeze_image is not None and self.freeze_image is not self.image:
         painter.setOpacity(0.3)
         painter.drawImage(0, 0, self.freeze_image)
开发者ID:NateShoffner,项目名称:PySnip-Map-Editor,代码行数:11,代码来源:run.py

示例4: resizeImage

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawImage [as 别名]
    def resizeImage(self, image, newSize):
        if image.size() == newSize:
            return
        newImage = QImage(newSize, QImage.Format_RGB32)
        newImage.fill(qRgb(255, 255, 255))
        painter = QPainter(newImage)
        painter.drawImage(QtCore.QPoint(0, 0), image)

        self.image = newImage
开发者ID:pouzzler,项目名称:IED-Logic-Simulator,代码行数:11,代码来源:circuitdrawing.py

示例5: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawImage [as 别名]
    def paintEvent(self, event):
        """
        Handles the ``paintEvent`` event for :class:`ImageWidget`.

        :param `event`: A `QPaintEvent`_ to be processed.
        """
        painter = QPainter(self)
        painter.drawPixmap(0, 0, self.pixmap)
        if self.parent.lightswitch.isOn: # Turn the light on.
            painter.drawImage(self.size().width() - 113, 1, self.lightOnImg)
开发者ID:Drahflow,项目名称:Embroidermodder,代码行数:12,代码来源:tipoftheday_dialog.py

示例6: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawImage [as 别名]
    def paintEvent(self, e):
        painter = QPainter(self)
        painter.setWorldTransform(QTransform().scale(0.5, 0.5))

        x = 0

        for i in self.images:
            painter.drawImage(QRect(x, 0, i.width(), i.height()), i)
            painter.drawRect(x, 0, i.width(), i.height())
            x += i.width()
开发者ID:Ingener74,项目名称:Silly-Crossbow,代码行数:12,代码来源:AberrantTiger.py

示例7: print_

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawImage [as 别名]
    def print_(self):
        canvas = self.mw.get_current_canvas()
        if not canvas:
            return

        printer = QPrinter()
        dlg = QPrintDialog(printer, self.mw)
        if dlg.exec_() == QDialog.Accepted:
            painter = QPainter(printer)
            painter.drawImage(0, 0, canvas.image)
            painter.end()
开发者ID:gil9red,项目名称:fake-painter,代码行数:13,代码来源:printer.py

示例8: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawImage [as 别名]
    def paintEvent(self, event):
        """
        Handles the ``paintEvent`` event for :class:`ImageWidget`.

        :param `event`: A `QPaintEvent`_ to be processed.
        """
        painter = QPainter(self)
        img = self.img
        width, height = img.width(), img.height()
        painter.setViewport(0, 0, width, height)
        painter.setWindow(0, 0, width, height)
        painter.drawImage(0, 0, img)
开发者ID:Allen76,项目名称:Embroidermodder,代码行数:14,代码来源:imagewidget.py

示例9: set_image

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawImage [as 别名]
 def set_image(self, image):
     self.dirty = True
     self.fill(0)
     painter = QPainter(self)
     painter.drawImage(0, 0, image)
开发者ID:NateShoffner,项目名称:PySnip-Map-Editor,代码行数:7,代码来源:run.py

示例10: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawImage [as 别名]
 def paintEvent(self, event):
     painter = QPainter(self)
     painter.drawImage(event.rect(), self.image)
     painter.drawImage(event.rect(), self.imagePreview)
     self.clearImagePreview()
开发者ID:pouzzler,项目名称:IED-Logic-Simulator,代码行数:7,代码来源:circuitdrawing.py

示例11: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawImage [as 别名]
 def paintEvent(self, event):
     painter = QPainter(self)
     painter.drawImage(QPoint(0, 0), self.qimage)
开发者ID:tfeldmann,项目名称:Biorobotic-Arm,代码行数:5,代码来源:videowidget.py


注:本文中的PySide.QtGui.QPainter.drawImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。