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


Python QPainter.drawPixmap方法代码示例

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


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

示例1: drawIconWithShadow

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawPixmap [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 drawPixmap [as 别名]
 def paintEvent(self, pe):
   painter = QPainter(self) 
   if self._fill:
     scaled_pixmap = self._image_pixmap.scaled(self.size(), Qt.IgnoreAspectRatio)
     painter.drawPixmap(0, 0, scaled_pixmap)
   else:
     painter.drawPixmap(0, 0, self._image_pixmap)
开发者ID:github-account-because-they-want-it,项目名称:VisualScrape,代码行数:9,代码来源:support.py

示例3: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawPixmap [as 别名]
 def paintEvent(self, pe):
   painter = QPainter(self)
   icon = QPixmap(self._icon)
   icon = icon.scaled(self.size(), Qt.IgnoreAspectRatio)
   if not self._mouse_over or not self._enabled:
     painter.setOpacity(self._normal_opacity)
   else:
     painter.setOpacity(self._hover_opacity)
   painter.drawPixmap(0, 0, icon)
开发者ID:github-account-because-they-want-it,项目名称:VisualScrape,代码行数:11,代码来源:common.py

示例4: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawPixmap [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

示例5: x_bitmap_opaque

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawPixmap [as 别名]
    def x_bitmap_opaque ( self, bitmap ):
        """ Returns a version of the specified bitmap with no transparency.
        """
        dx = bitmap.width()
        dy = bitmap.height()
        opaque_bitmap = QPixmap( dx, dy )
        opaque_bitmap.fill( WindowColor )
        q = QPainter( opaque_bitmap )
        q.drawPixmap( 0, 0, bitmap )

        return opaque_bitmap
开发者ID:davidmorrill,项目名称:facets,代码行数:13,代码来源:image_slice.py

示例6: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawPixmap [as 别名]
    def paintEvent(self, event):
        mouse_pos = self.mapFromGlobal(QCursor.pos())
        is_hover = self.contentsRect().contains(mouse_pos)

        QPushButton.paintEvent(self, event)

        painter = QPainter(self)
        painter.drawPixmap(2, 1, self.icon)
        if is_hover:
            painter.setCompositionMode(QPainter.CompositionMode_Screen)
            painter.drawPixmap(2, 1, self.icon)
开发者ID:Bioeden,项目名称:dbMayaTextureToolkit,代码行数:13,代码来源:mttCustomWidget.py

示例7: paintEvent

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

        :param `event`: a `QPaintEvent` event to be processed.
        """
        painter = QPainter(self)

        painter.drawPixmap(0, 0, self.pixmap)
        # Draw the overlays.
        if self.paintThisText == 'About':
            painter.drawPixmap(20, 15, self.pixmap1ForPaintEvent)
开发者ID:JTrantow,项目名称:Embroidermodder,代码行数:14,代码来源:dialog_about.py

示例8: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawPixmap [as 别名]
 def paintEvent(self, event):
     painter = QPainter()
     painter.begin(self)
     painter.setRenderHint(QPainter.HighQualityAntialiasing)
     painter.setRenderHint(QPainter.Antialiasing)
     painter.setRenderHint(QPainter.SmoothPixmapTransform)
     painter.setBrush(self.color)
     if self.effect_size == self.radius:
         painter.drawEllipse(1, 1, self.radius - 1, self.radius - 1)
         painter.drawPixmap(QRect(14, 14, self.radius / 2, self.radius / 2), self.pixmap)
     else:
         painter.drawEllipse(self.width() / 2, self.height() / 2, self.effect_size, self.effect_size)
     painter.end()
开发者ID:ethanhs,项目名称:material,代码行数:15,代码来源:material.py

示例9: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawPixmap [as 别名]
	def paintEvent(self, event):
		painter = QPainter(self)

		painter.setBrush(Qt.white)
		painter.drawRect(self.rect())

		painter.translate(self.width()/2, self.height()/2)

		if self.pixReady:
			grammarPix = QPixmap("/tmp/grammar.png")
			pw = grammarPix.width()
			ph = grammarPix.height()
			painter.drawPixmap(-pw/2, -ph/2, grammarPix)
开发者ID:omartinak,项目名称:cfree,代码行数:15,代码来源:paintArea.py

示例10: capture

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawPixmap [as 别名]
    def capture(self):
        app.processEvents()

        print "caught capture",('tmp_{}_{:'+self.fmt+'}.jpg').format(self.UID,self.capture_count)
        print "current fps",float(self.capture_count)/(time.time()-self.start_capture_time)
        if not self.snap_shots.queue.empty():
            self.snap_shots.queue.get(0)
            arrow = QPixmap(self.arrow_icon);
            self.px = QPixmap.grabWindow(QApplication.desktop().winId())
            painter = QPainter(self.px)
            painter.drawPixmap(QCursor.pos(), arrow)
            if(self.options.capture_area_sa.isChecked()):
                self.px2 = self.px.copy(self.options.sa_x.value(),
                                        self.options.sa_y.value(),
                                        self.options.sa_w.value(),
                                        self.options.sa_h.value())
            else:
                self.px2 = self.px
            self.px2.save(('tmp_{}_{:'+self.fmt+'}.jpg').format(self.UID,self.capture_count), 'jpg')
            self.capture_count+=1
开发者ID:marcrobinson,项目名称:marcrobinson.github.io,代码行数:22,代码来源:capture.py

示例11: paintEvent

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

        :param `event`: A `QPaintEvent`_ to be processed.
        """
        vport = self.viewport()
        rect = vport.rect()

        painter = QPainter(vport)
        painter.setRenderHint(painter.SmoothPixmapTransform)

        # Always fill with a solid color first
        if self.useColor:
            # painter.fillRect(rect, self.colorBrush)
            painter.fillRect(rect, self.bgColor)
        else:
            painter.fillRect(rect, self.background())

        # Then overlay the texture
        if self.useTexture:
            # painter.fillRect(rect, self.backgroundBrush)
            bgBrush = QBrush(self.bgTexture)
            painter.fillRect(rect, bgBrush)
            

        # Overlay the logo last
        if self.useLogo:
            if not len(self.subWindowList()):  # Nothing is open.
                cSizeW, cSizeH = rect.width(), rect.height()
                bgLogoW, bgLogoH = self.bgLogo.width(), self.bgLogo.height()
                if bgLogoW > cSizeW:
                    # Proportional Scaling an Image.
                    newHeight = bgLogoH * cSizeW // bgLogoW
                    scaledLogo = self.bgLogo.scaled(cSizeW, newHeight)
                    painter.drawPixmap(0,
                                       cSizeH // 2 - scaledLogo.height() // 2,
                                       scaledLogo)
                else:
                    painter.drawPixmap((cSizeW - bgLogoW) // 2,
                                       (cSizeH - bgLogoH) // 2,
                                       self.bgLogo)
            else:
                # Center the pixmap
                dx = (rect.width() - self.bgLogo.width()) / 2
                dy = (rect.height() - self.bgLogo.height()) / 2
                painter.drawPixmap(dx, dy,
                                   self.bgLogo.width(), self.bgLogo.height(),
                                   self.bgLogo)
开发者ID:Allen76,项目名称:Embroidermodder,代码行数:51,代码来源:mdiarea.py


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