本文整理汇总了Python中PyQt4.QtGui.QImageReader.setScaledSize方法的典型用法代码示例。如果您正苦于以下问题:Python QImageReader.setScaledSize方法的具体用法?Python QImageReader.setScaledSize怎么用?Python QImageReader.setScaledSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QImageReader
的用法示例。
在下文中一共展示了QImageReader.setScaledSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_archive_wallpapers
# 需要导入模块: from PyQt4.QtGui import QImageReader [as 别名]
# 或者: from PyQt4.QtGui.QImageReader import setScaledSize [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)
示例2: update
# 需要导入模块: from PyQt4.QtGui import QImageReader [as 别名]
# 或者: from PyQt4.QtGui.QImageReader import setScaledSize [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)