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


Python QImage.fromData方法代码示例

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


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

示例1: load_image

# 需要导入模块: from PyQt4.Qt import QImage [as 别名]
# 或者: from PyQt4.Qt.QImage import fromData [as 别名]
 def load_image(self, data):
     self.is_valid = False
     try:
         fmt = identify_data(data)[-1].encode('ascii')
     except Exception:
         fmt = b''
     self.original_image_format = fmt.decode('ascii').lower()
     self.selection_state.reset()
     self.original_image_data = data
     self.current_image = i = self.original_image = (
         QImage.fromData(data, format=fmt) if fmt else QImage.fromData(data))
     self.is_valid = not i.isNull()
     self.update()
     self.image_changed.emit(self.current_image)
开发者ID:pwasiewi,项目名称:calibre,代码行数:16,代码来源:canvas.py

示例2: magick_to_qimage

# 需要导入模块: from PyQt4.Qt import QImage [as 别名]
# 或者: from PyQt4.Qt.QImage import fromData [as 别名]
def magick_to_qimage(img):
    fmt = get_pixel_map()
    # ImageMagick can output only output raw data in some formats that can be
    # read into QImage directly, if the QImage format is not one of those, use
    # PNG
    if fmt in {'RGBA', 'BGRA'}:
        w, h = img.size
        img.depth = 8  # QImage expects 8bpp
        raw = img.export(fmt)
        i = QImage(raw, w, h, QImage.Format_ARGB32)
        del raw  # According to the documentation, raw is supposed to not be deleted, but it works, so make it explicit
        return i
    else:
        raw = img.export('PNG')
        return QImage.fromData(QByteArray(raw), 'PNG')
开发者ID:pwasiewi,项目名称:calibre,代码行数:17,代码来源:canvas.py

示例3: get_service_icon

# 需要导入模块: from PyQt4.Qt import QImage [as 别名]
# 或者: from PyQt4.Qt.QImage import fromData [as 别名]
 def get_service_icon(self, id, name, url):
     icon, st = None, self.app.preferences.settings
     if not st.contains('icon/'+name):
         icon = get_favicon(url)
         if icon:
             icon = QIcon(QPixmap.fromImage(QImage.fromData(icon)))
             print name, "icon loaded?", not icon.isNull()
             if not icon.isNull():
                 st.setValue('icon/'+name, icon)
         else: print "error while loading", name, "icon"
     else:
         icon = st.value('icon/'+name, None)
         if icon: icon = QIcon(icon)
     if icon:
         self.app.preferences.ui.accountsTabWidget.setTabIcon(id, icon)
     return icon
开发者ID:koeart,项目名称:blain,代码行数:18,代码来源:icons.py

示例4: get_service_icon

# 需要导入模块: from PyQt4.Qt import QImage [as 别名]
# 或者: from PyQt4.Qt.QImage import fromData [as 别名]
 def get_service_icon(self, name, url):
     key = "service/" + name
     if key in self.icons:
         return self.icons[key]
     icon, st = None, self.app.accounts.settings
     if not st.contains('icon/'+name):
         icon = get_favicon(url)
         if icon:
             icon = QIcon(QPixmap.fromImage(QImage.fromData(icon)))
             #print name, "icon loaded?", not icon.isNull()
             if not icon.isNull():
                 st.setValue('icon/'+name, icon)
         else: print "[ERROR] while loading", name, "icon"
     else:
         icon = st.value('icon/'+name, None)
         if icon: icon = QIcon(icon)
     if icon:
         self.icons[key] = icon
     return icon
开发者ID:dodo,项目名称:blain,代码行数:21,代码来源:icons.py


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