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


Python QPixmap.toImage方法代码示例

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


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

示例1: testWithString

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import toImage [as 别名]
    def testWithString(self):
        pm1 = QPixmap()
        ok = QPixmapCache.find('img', pm1)
        self.assertFalse(ok)

        self.assertEqual(QPixmapCache.find('img'), None)

        pm2 = QPixmap()
        ok = QPixmapCache.insert('img', pm2)
        self.assertTrue(ok)

        pm3 = QPixmap()
        ok = QPixmapCache.find('img', pm3)
        self.assertTrue(ok)
        b1 = QPixmapCache.find('img').toImage().bits()
        b2 = pm3.toImage().bits()
        self.assertEqual(QPixmapCache.find('img').toImage().bits(), pm3.toImage().bits())
开发者ID:Hasimir,项目名称:PySide,代码行数:19,代码来源:qpixmapcache_test.py

示例2: QPixmapQDatastream

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import toImage [as 别名]
class QPixmapQDatastream(UsesQApplication):
    '''QDataStream <<>> QPixmap'''

    def setUp(self):
        super(QPixmapQDatastream, self).setUp()
        self.source_pixmap = QPixmap(100, 100)
        self.source_pixmap.fill(Qt.red)
        self.output_pixmap = QPixmap()
        self.buffer = QByteArray()
        self.read_stream = QDataStream(self.buffer, QIODevice.ReadOnly)
        self.write_stream = QDataStream(self.buffer, QIODevice.WriteOnly)

    def testStream(self):
        self.write_stream << self.source_pixmap

        self.read_stream >> self.output_pixmap

        image = self.output_pixmap.toImage()
        pixel = image.pixel(10,10)
        self.assertEqual(pixel, QColor(Qt.red).rgba())
        self.assertEqual(self.source_pixmap.toImage(), self.output_pixmap.toImage())
开发者ID:Hasimir,项目名称:PySide,代码行数:23,代码来源:qdatastream_gui_operators_test.py

示例3: testWithKey

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import toImage [as 别名]
    def testWithKey(self):
        pm1 = QPixmap()
        ok = QPixmapCache.find(QPixmapCache.Key(), pm1)
        self.assertFalse(ok)

        self.assertEqual(QPixmapCache.find(QPixmapCache.Key()), None)

        pm2 = QPixmap()
        key = QPixmapCache.insert(pm2)

        pm3 = QPixmap()
        ok = QPixmapCache.find(key, pm3)
        self.assertTrue(ok)

        self.assertEqual(QPixmapCache.find(key).toImage().bits(), pm3.toImage().bits())
开发者ID:Hasimir,项目名称:PySide,代码行数:17,代码来源:qpixmapcache_test.py

示例4: tag_image

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import toImage [as 别名]
def tag_image(source, dest, tag, font, fontsize, x, y, width, height, aspectx, aspecty, red, green, blue, bold=False, italic=False):
    """docstring for tag_image"""

    app = QApplication.instance()
    
    pixmap = QPixmap(source)

    color = QColor(red,green,blue)
    font = QFont(font)
    font.setPixelSize(int(fontsize*pixmap.height()))
    font.setItalic(italic)
    font.setBold(bold)

    painter = QPainter(pixmap)
    painter.setPen(color)
    painter.setFont(font);
    painter.drawText(x*pixmap.width(),y*pixmap.height(), tag)
    painter.end()

    # Resize and save
    return pixmap.toImage().scaled(width*aspectx, height*aspecty, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation).scaled(width, height, Qt.IgnoreAspectRatio, Qt.SmoothTransformation).save(dest)
开发者ID:eyeonSoftware,项目名称:epp,代码行数:23,代码来源:epp_addshot.py


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