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


Python QImageReader.read方法代码示例

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


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

示例1: get_archive_wallpapers

# 需要导入模块: from PyQt4.QtGui import QImageReader [as 别名]
# 或者: from PyQt4.QtGui.QImageReader import read [as 别名]
    def get_archive_wallpapers(self):
        """
        Generator returning the date, path and copyright info (via db lookup) of each file found in the
        archive location.

        :rtype: QDate, unicode, unicode
        """
        image_reader = QImageReader()
        regex_date_split = re.compile(r'(\d{4})(\d{2})(\d{2})')

        copyright_info = self.copyright_db.get_all_info()
        archive_folder = self.settings.archive_location
        for filename in reversed([x for x in os.listdir(archive_folder) if re_archive_file.match(x)]):
            year, month, day = map(int, regex_date_split.findall(filename)[0])
            wallpaper_date = QDate(year, month, day)
            wallpaper_copyright = copyright_info.get('{0:04d}-{1:02d}-{2:02d}'.format(year, month, day), '')
            wallpaper_filename = os.path.join(unicode(archive_folder), filename)

            image_reader.setFileName(wallpaper_filename)
            image_size = image_reader.size()
            image_size.scale(QSize(200, 125), Qt.IgnoreAspectRatio)
            image_reader.setScaledSize(image_size)
            thumbnail_image = image_reader.read()
            if thumbnail_image.isNull():
                continue
            self.lw_wallpaper_history.add_item(thumbnail_image, wallpaper_date, wallpaper_copyright,
                                               archive_path=wallpaper_filename)
            self.app.processEvents()
        self.lw_wallpaper_history.sortItems(Qt.AscendingOrder)
开发者ID:se0siris,项目名称:bing-wallpaper-changer,代码行数:31,代码来源:mainwindow.py

示例2: returnAvatar

# 需要导入模块: from PyQt4.QtGui import QImageReader [as 别名]
# 或者: from PyQt4.QtGui.QImageReader import read [as 别名]
    def returnAvatar(self, reply):
        imageReader = QImageReader(reply)
        image = imageReader.read()

        lbl = self.ui.avatarLB
        if reply.error() == QNetworkReply.NoError:
            pixMap = QPixmap.fromImage(image).scaled(lbl.size(), Qt.KeepAspectRatio)
            lbl.setPixmap(pixMap)
            lbl.show()
        else:
            # TODO Put default image if not load from URL.
            pass
开发者ID:gkudos,项目名称:qgis-cartodb,代码行数:14,代码来源:UserData.py

示例3: update

# 需要导入模块: from PyQt4.QtGui import QImageReader [as 别名]
# 或者: from PyQt4.QtGui.QImageReader import read [as 别名]
    def update(self):
        """ Fonction de mise à jour de la préview :
            * Si la taille de l'image est plus petite que la taille souhaité, on n'agrandi pas l'image, on prend la plus petite des deux
            * Le cache contient en index les images+size"""
        miniImg = QImage()
        image = QImageReader(self.imageName)
        self.origineSize = image.size()
        image.setQuality(self.quality)
        if not self.magnify :
            if ( ( self.size.width() + self.size.height() ) > (image.size().width() + image.size().height() ) ) :
                self.size = image.size()

        if self.keepRatio :
            image.setScaledSize(QSize(self.size.width(), image.size().height() * self.size.width() / image.size().width() ) )
        else :
            image.setScaledSize(self.size)

        if not QPixmapCache.find(self.imageName + str(self.size), self.preview) or not self.cache:
            image.read(miniImg)
            self.preview = self.preview.fromImage(miniImg)
            if self.cache :
                QPixmapCache.insert(self.imageName + str(self.size), self.preview)
开发者ID:Ptaah,项目名称:Ekd,代码行数:24,代码来源:EkdWidgets.py

示例4: returnAvatar

# 需要导入模块: from PyQt4.QtGui import QImageReader [as 别名]
# 或者: from PyQt4.QtGui.QImageReader import read [as 别名]
    def returnAvatar(self, reply):
        imageReader = QImageReader(reply)
        self.avatarImage = imageReader.read()

        lbl = self.avatarLB
        if reply.error() == QNetworkReply.NoError:
            pixMap = QPixmap.fromImage(self.avatarImage).scaled(lbl.size(), Qt.KeepAspectRatio)
            lbl.setPixmap(pixMap)
            lbl.show()
        else:
            # TODO Put default image if not load from URL.
            pass

        self.nameLB.setText("<html><head/><body><p><span style=\" text-decoration: underline; color:#00557f;\">" + self.currentUser + "</span></p></body></html>")
开发者ID:gkudos,项目名称:qgis-cartodb,代码行数:16,代码来源:CartoDBToolbar.py

示例5: on_reply_ready

# 需要导入模块: from PyQt4.QtGui import QImageReader [as 别名]
# 或者: from PyQt4.QtGui.QImageReader import read [as 别名]
        def on_reply_ready(reply, future):
            nonlocal n_redir
            # schedule deferred delete to ensure the reply is closed
            # otherwise we will leak file/socket descriptors
            reply.deleteLater()
            future._reply = None
            if reply.error() == QNetworkReply.OperationCanceledError:
                # The network request was cancelled
                reply.close()
                future.cancel()
                return

            if reply.error() != QNetworkReply.NoError:
                # XXX Maybe convert the error into standard
                # http and urllib exceptions.
                future.set_exception(Exception(reply.errorString()))
                reply.close()
                return

            # Handle a possible redirection
            location = reply.attribute(
                QNetworkRequest.RedirectionTargetAttribute)

            if location is not None and n_redir < 1:
                n_redir += 1
                location = reply.url().resolved(location)
                # Retry the original request with a new url.
                request = QNetworkRequest(reply.request())
                request.setUrl(location)
                newreply = self._netmanager.get(request)
                future._reply = newreply
                newreply.finished.connect(
                    partial(on_reply_ready, newreply, future))
                reply.close()
                return

            reader = QImageReader(reply)
            image = reader.read()
            reply.close()

            if image.isNull():
                future.set_exception(Exception(reader.errorString()))
            else:
                future.set_result(image)
开发者ID:BlazZupan,项目名称:orange3,代码行数:46,代码来源:owimageviewer.py

示例6: on_reply_ready

# 需要导入模块: from PyQt4.QtGui import QImageReader [as 别名]
# 或者: from PyQt4.QtGui.QImageReader import read [as 别名]
        def on_reply_ready(reply, future):
            nonlocal n_redir
            if reply.error() == QNetworkReply.OperationCanceledError:
                # The network request itself was canceled
                future.cancel()
                return

            if reply.error() != QNetworkReply.NoError:
                # XXX Maybe convert the error into standard
                # http and urllib exceptions.
                future.set_exception(Exception(reply.errorString()))
                return

            # Handle a possible redirection
            location = reply.attribute(
                QNetworkRequest.RedirectionTargetAttribute)

            if location is not None and n_redir < 1:
                n_redir += 1
                print(location)
                location = reply.url().resolved(location)
                # Retry the original request with a new url.
                request = QNetworkRequest(reply.request())
                request.setUrl(location)
                newreply = self._netmanager.get(request)
                future._reply = newreply
                newreply.finished.connect(
                    partial(on_reply_ready, newreply, future))
                return

            reader = QImageReader(reply)
            image = reader.read()

            if image.isNull():
                future.set_exception(Exception(reader.errorString()))
            else:
                future.set_result(image)
开发者ID:Micseb,项目名称:orange3,代码行数:39,代码来源:owimageviewer.py

示例7: setupScene

# 需要导入模块: from PyQt4.QtGui import QImageReader [as 别名]
# 或者: from PyQt4.QtGui.QImageReader import read [as 别名]
    def setupScene(self):
        self.error()
        if self.data:
            attr = self.stringAttrs[self.imageAttr]
            titleAttr = self.allAttrs[self.titleAttr]
            instances = [inst for inst in self.data
                         if numpy.isfinite(inst[attr])]
            assert self.thumbnailView.count() == 0
            size = QSizeF(self.imageSize, self.imageSize)

            for i, inst in enumerate(instances):
                url = self.urlFromValue(inst[attr])
                title = str(inst[titleAttr])

                thumbnail = GraphicsThumbnailWidget(QPixmap(), title=title)
                thumbnail.setThumbnailSize(size)
                thumbnail.setToolTip(url.toString())
                thumbnail.instance = inst
                self.thumbnailView.addThumbnail(thumbnail)

                if url.isValid() and url.isLocalFile():
                    reader = QImageReader(url.toLocalFile())
                    image = reader.read()
                    if image.isNull():
                        error = reader.errorString()
                        thumbnail.setToolTip(
                            thumbnail.toolTip() + "\n" + error)
                        self._errcount += 1
                    else:
                        pixmap = QPixmap.fromImage(image)
                        thumbnail.setPixmap(pixmap)
                        self._successcount += 1

                    future = Future()
                    future.set_result(image)
                    future._reply = None
                elif url.isValid():
                    future = self.loader.get(url)

                    @future.add_done_callback
                    def set_pixmap(future, thumb=thumbnail):
                        if future.cancelled():
                            return

                        assert future.done()

                        if future.exception():
                            # Should be some generic error image.
                            pixmap = QPixmap()
                            thumb.setToolTip(thumb.toolTip() + "\n" +
                                             str(future.exception()))
                        else:
                            pixmap = QPixmap.fromImage(future.result())

                        thumb.setPixmap(pixmap)

                        self._noteCompleted(future)
                else:
                    future = None

                self.items.append(_ImageItem(i, thumbnail, url, future))

            if any(it.future is not None and not it.future.done()
                   for it in self.items):
                self.info.setText("Retrieving...\n")
            else:
                self._updateStatus()
开发者ID:BlazZupan,项目名称:orange3,代码行数:69,代码来源:owimageviewer.py


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