本文整理汇总了Python中PyQt4.Qt.QImage.scaledToWidth方法的典型用法代码示例。如果您正苦于以下问题:Python QImage.scaledToWidth方法的具体用法?Python QImage.scaledToWidth怎么用?Python QImage.scaledToWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QImage
的用法示例。
在下文中一共展示了QImage.scaledToWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _populate_covers
# 需要导入模块: from PyQt4.Qt import QImage [as 别名]
# 或者: from PyQt4.Qt.QImage import scaledToWidth [as 别名]
#.........这里部分代码省略.........
QSize(m_image.width(),
m_image.height()))
m_painter = QPainter(self.m_pixmap)
m_painter.setRenderHints(m_painter.Antialiasing)
m_painter.drawImage(0, 0, m_image)
self.marvin_cover.setPixmap(self.m_pixmap)
else:
# No cover available, use generic
self._log("No cached cover, using generic")
pixmap = QPixmap()
pixmap.load(I('book.png'))
pixmap = pixmap.scaled(self.COVER_ICON_SIZE,
self.COVER_ICON_SIZE,
aspectRatioMode=Qt.KeepAspectRatio,
transformMode=Qt.SmoothTransformation)
self.marvin_cover.setPixmap(pixmap)
self.calibre_cover.setMaximumSize(QSize(self.COVER_ICON_SIZE, self.COVER_ICON_SIZE))
self.calibre_cover.setText('')
self.calibre_cover.setScaledContents(False)
self.marvin_cover.setMaximumSize(QSize(self.COVER_ICON_SIZE, self.COVER_ICON_SIZE))
self.marvin_cover.setText('')
self.marvin_cover.setScaledContents(False)
if self.cid:
db = self.opts.gui.current_db
if 'cover_hash' not in self.mismatches:
mi = db.get_metadata(self.cid, index_is_id=True, get_cover=True, cover_as_data=True)
c_image = QImage()
if mi.has_cover:
c_image.loadFromData(mi.cover_data[1])
c_image = c_image.scaledToHeight(self.COVER_ICON_SIZE,
Qt.SmoothTransformation)
self.c_pixmap = QPixmap(QSize(c_image.width(),
c_image.height()))
c_painter = QPainter(self.c_pixmap)
c_painter.setRenderHints(c_painter.Antialiasing)
c_painter.drawImage(0, 0, c_image)
else:
c_image.load(I('book.png'))
c_image = c_image.scaledToWidth(135,
Qt.SmoothTransformation)
# Construct a QPixmap with dialog background
self.c_pixmap = QPixmap(
QSize(c_image.width(),
c_image.height()))
c_painter = QPainter(self.c_pixmap)
c_painter.setRenderHints(c_painter.Antialiasing)
bgcolor = self.palette().color(QPalette.Background)
c_painter.fillRect(self.c_pixmap.rect(), bgcolor)
c_painter.drawImage(0, 0, c_image)
# Set calibre cover
self.calibre_cover.setPixmap(self.c_pixmap)
if self.opts.prefs.get('development_mode', False):
# Show individual covers
_fetch_marvin_cover()
else:
# Show calibre cover on both sides
self.marvin_cover.setPixmap(self.c_pixmap)
else:
# Covers don't match - render with border
# Construct a QImage with the cover sized to fit inside border
c_image = QImage()
cdata = db.cover(self.cid, index_is_id=True)
if cdata is None:
c_image.load(I('book.png'))
self.calibre_cover.setScaledContents(True)
else:
c_image.loadFromData(cdata)
c_image = c_image.scaledToHeight(
self.COVER_ICON_SIZE - self.BORDER_WIDTH * 2,
Qt.SmoothTransformation)
# Construct a QPixmap with yellow background
self.c_pixmap = QPixmap(
QSize(c_image.width() + self.BORDER_WIDTH * 2,
c_image.height() + self.BORDER_WIDTH * 2))
c_painter = QPainter(self.c_pixmap)
c_painter.setRenderHints(c_painter.Antialiasing)
c_painter.fillRect(self.c_pixmap.rect(),self.MISMATCH_COLOR)
c_painter.drawImage(self.BORDER_WIDTH, self.BORDER_WIDTH, c_image)
self.calibre_cover.setPixmap(self.c_pixmap)
# Render Marvin cover with small border if different covers,
# large cover if no cover hash (loaded via OPDS)
border_width = self.BORDER_WIDTH
if self.mismatches['cover_hash']['Marvin'] is None:
border_width = self.BORDER_WIDTH * 3
_fetch_marvin_cover(border_width=border_width)
else:
_fetch_marvin_cover()