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


Python QIODevice.ReadWrite方法代码示例

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


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

示例1: fromqimage

# 需要导入模块: from PyQt4.QtCore import QIODevice [as 别名]
# 或者: from PyQt4.QtCore.QIODevice import ReadWrite [as 别名]
def fromqimage(im):
    buffer = QBuffer()
    buffer.open(QIODevice.ReadWrite)
    # preserve alha channel with png
    # otherwise ppm is more friendly with Image.open
    if im.hasAlphaChannel():
        im.save(buffer, 'png')
    else:
        im.save(buffer, 'ppm')

    b = BytesIO()
    try:
        b.write(buffer.data())
    except TypeError:
        # workaround for Python 2
        b.write(str(buffer.data()))
    buffer.close()
    b.seek(0)

    return Image.open(b) 
开发者ID:robinchenyu,项目名称:imagepaste,代码行数:22,代码来源:ImageQt.py

示例2: fromqimage

# 需要导入模块: from PyQt4.QtCore import QIODevice [as 别名]
# 或者: from PyQt4.QtCore.QIODevice import ReadWrite [as 别名]
def fromqimage(im):
    """
    :param im: A PIL Image object, or a file name
    (given either as Python string or a PyQt string object)
    """
    buffer = QBuffer()
    buffer.open(QIODevice.ReadWrite)
    # preserve alha channel with png
    # otherwise ppm is more friendly with Image.open
    if im.hasAlphaChannel():
        im.save(buffer, 'png')
    else:
        im.save(buffer, 'ppm')

    b = BytesIO()
    try:
        b.write(buffer.data())
    except TypeError:
        # workaround for Python 2
        b.write(str(buffer.data()))
    buffer.close()
    b.seek(0)

    return Image.open(b) 
开发者ID:it2school,项目名称:Projects,代码行数:26,代码来源:ImageQt.py

示例3: fromqpixmap

# 需要导入模块: from PyQt4.QtCore import QIODevice [as 别名]
# 或者: from PyQt4.QtCore.QIODevice import ReadWrite [as 别名]
def fromqpixmap(im):
    return fromqimage(im)
    # buffer = QBuffer()
    # buffer.open(QIODevice.ReadWrite)
    # # im.save(buffer)
    # # What if png doesn't support some image features like animation?
    # im.save(buffer, 'ppm')
    # bytes_io = BytesIO()
    # bytes_io.write(buffer.data())
    # buffer.close()
    # bytes_io.seek(0)
    # return Image.open(bytes_io) 
开发者ID:robinchenyu,项目名称:imagepaste,代码行数:14,代码来源:ImageQt.py


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