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


Python QtCore.QBuffer方法代碼示例

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


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

示例1: fromqimage

# 需要導入模塊: from PySide import QtCore [as 別名]
# 或者: from PySide.QtCore import QBuffer [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:tp4a,項目名稱:teleport,代碼行數:26,代碼來源:ImageQt.py

示例2: fromqimage

# 需要導入模塊: from PySide import QtCore [as 別名]
# 或者: from PySide.QtCore import QBuffer [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 alpha 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:holzschu,項目名稱:python3_ios,代碼行數:26,代碼來源:ImageQt.py

示例3: getIcon

# 需要導入模塊: from PySide import QtCore [as 別名]
# 或者: from PySide.QtCore import QBuffer [as 別名]
def getIcon(obj,disabled=False,path=None):
    if not path:
        path = iconPath
    if not getattr(obj,'_icon',None):
        obj._icon = addIconToFCAD(obj._iconName,path)
    if not disabled:
        return obj._icon
    if not getattr(obj,'_iconDisabled',None):
        name = getattr(obj,'_iconDisabledName',None)
        if name:
            obj._iconDisabled = addIconToFCAD(name,path)
        else:
            key = os.path.join(path,obj._iconName) + '.disabled'
            fmt = None
            try:
                if FreeCADGui.isIconCached(key):
                    obj._iconDisabled = key
                    return key
                else:
                    fmt = 'PNG'
            except Exception:
                pass
            pixmap = FreeCADGui.getIcon(obj._icon).pixmap(*iconSize,mode=QIcon.Disabled)
            icon = QIcon(pixmapDisabled)
            icon.paint(QPainter(pixmap),0,0,iconSize[0],iconSize[1],Qt.AlignCenter)
            data = QByteArray()
            buf = QBuffer(data)
            buf.open(QIODevice.WriteOnly)
            if fmt:
                pixmap.save(buf, fmt)
                FreeCADGui.addIcon(key,data.data(),fmt)
            else:
                pixmap.save(buf, 'XPM')
                key = data.data().decode('latin1')
            obj._iconDisabled = key
    return obj._iconDisabled 
開發者ID:realthunder,項目名稱:FreeCAD_assembly3,代碼行數:38,代碼來源:utils.py

示例4: fromqpixmap

# 需要導入模塊: from PySide import QtCore [as 別名]
# 或者: from PySide.QtCore import QBuffer [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:tp4a,項目名稱:teleport,代碼行數:14,代碼來源:ImageQt.py

示例5: _qimage_to_pil_image

# 需要導入模塊: from PySide import QtCore [as 別名]
# 或者: from PySide.QtCore import QBuffer [as 別名]
def _qimage_to_pil_image(qimg):
        buffer = QtCore.QBuffer()
        buffer.open(QtCore.QIODevice.ReadWrite)
        qimg.save(buffer, "PNG")

        bytes_io = io.BytesIO()
        bytes_io.write(buffer.data().data())
        buffer.close()
        bytes_io.seek(0)
        return Image.open(bytes_io) 
開發者ID:LumenResearch,項目名稱:heatmappy,代碼行數:12,代碼來源:heatmap.py


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