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


Python QImage.isNull方法代码示例

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


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

示例1: requestImage

# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import isNull [as 别名]
    def requestImage(self, id, size, requestedSize):
        key = (id, requestedSize)
        if key in self._cache:
            return self._cache[key]

        cover_file, cover_url, podcast_url, podcast_title = id.split('|')

        def get_filename():
            return self.downloader.get_cover(cover_file, cover_url,
                    podcast_url, podcast_title, None, None, True)

        filename = get_filename()

        image = QImage()
        if not image.load(filename):
            if filename.startswith(cover_file):
                logger.info('Deleting broken cover art: %s', filename)
                util.delete_file(filename)
                image.load(get_filename())

        if not image.isNull():
            self._cache[key] = image.scaled(requestedSize,
                    Qt.KeepAspectRatioByExpanding,
                    Qt.SmoothTransformation)

        return self._cache[key]
开发者ID:billy40,项目名称:gpodder,代码行数:28,代码来源:images.py

示例2: Country

# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import isNull [as 别名]
class Country(object):
    '''
    ISO 3166 Country Class
    
    Holds information about a Country including its name, ISO 3166 code, and 
    a Qt Image of the country flag, if the resource is available.  The flag
    image should reside in the resource /flags/xx.png, where xx is the two-
    character lower-case country code.
    '''
    def __init__(self, code):
        self.code = code.upper()
        self._flag = None
        self._icon = None
    
    def __unicode__(self):
        return unicode(self.code or u'')

    def __eq__(self, other):
        return unicode(self) == unicode(other)

    def __ne__(self, other):
        return not self.__eq__(other)

    def __cmp__(self, other):
        return cmp(unicode(self), unicode(other))

    def __hash__(self):
        return hash(unicode(self))

    def __repr__(self):
        return "%s(code=%r)" % (self.__class__.__name__, unicode(self))

    def __nonzero__(self):
        return bool(self.code)

    def __len__(self):
        return len(unicode(self))
    
    @property
    def name(self):
        # Local import so the countries aren't loaded unless they are needed. 
        from countries import COUNTRIES
        for code, name in COUNTRIES:
            if self.code.upper() == code.upper():
                return name
        return ''
    
    @property
    def flag(self):
        # Load flag image from resource
        if not self._flag:
            from PySide.QtGui import QImage 
            self._flag = QImage(':/flags/%s.png' % self.code.lower())
        return self._flag if not self._flag.isNull() else None
    
    @property
    def icon(self):
        # Load flag icon from resource
        from PySide.QtGui import QIcon
        return QIcon(':/flags/%s.png' % self.code.lower())
开发者ID:asymworks,项目名称:python-divelog,代码行数:62,代码来源:types.py

示例3: image_from_hbitmap

# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import isNull [as 别名]
def image_from_hbitmap(hdc, bitmap, width, height):
    bitmap_info = BITMAPINFO()
    memset(byref(bitmap_info), 0, sizeof(bitmap_info))
    bitmap_info.bmiHeader.biSize = sizeof(bitmap_info.bmiHeader)
    bitmap_info.bmiHeader.biWidth = width
    bitmap_info.bmiHeader.biHeight = -height
    bitmap_info.bmiHeader.biPlanes = 1
    bitmap_info.bmiHeader.biBitCount = 32
    bitmap_info.bmiHeader.biCompression = BI_RGB
    bitmap_info.bmiHeader.biSizeImage = width * height * 4
    image = QImage(width, height, QImage.Format_ARGB32_Premultiplied)
    if image.isNull(): return image
    data = (c_ubyte * bitmap_info.bmiHeader.biSizeImage)()
    if not GetDIBits(hdc, bitmap, 0, height, data, byref(bitmap_info), 
            DIB_RGB_COLORS):
        raise WindowsError('call to GetDIBits failed')
    bytes_per_line = image.bytesPerLine()
    for y in xrange(0, height):
        offset = y * bytes_per_line
        line = image.scanLine(y)
        for x in xrange(0, bytes_per_line):
            line[x] = chr(data[offset + x])
    return image
开发者ID:vstojkovic,项目名称:berk,代码行数:25,代码来源:win32_icon_provider.py


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