[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeplasma-addons/applets/nowplaying
From: Michael Pyne <mpyne () purinchu ! net>
Date: 2009-02-28 6:15:51
Message-ID: 1235801751.447546.14592.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 933144 by mpyne:
Improve image quality of scaled-down image art in NowPlaying. For some reason \
SmoothPixmapTransform in QPainter doesn't seem as effective as QPixmap's own smooth \
image transformation.
M +15 -7 albumart.cpp
M +1 -0 albumart.h
--- trunk/KDE/kdeplasma-addons/applets/nowplaying/albumart.cpp #933143:933144
@@ -42,19 +42,27 @@
{
Q_UNUSED(widget);
- if (!m_pixmap.isNull())
- {
- painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
- qreal inverseScaleFactor = qMax(m_pixmap.width() / size().width(), \
m_pixmap.height() / size().height());
- QRectF sourceRect = option->exposedRect;
- sourceRect.setSize(sourceRect.size() * inverseScaleFactor);
- painter->drawPixmap(option->exposedRect, m_pixmap, sourceRect);
+ if (m_pixmap.isNull())
+ return;
+
+ if (m_scaledPixmap.size() != size()) {
+ QSize scaledSize (m_pixmap.size());
+ scaledSize.scale (size().toSize(), Qt::KeepAspectRatio);
+
+ if (m_scaledPixmap.size() != scaledSize) {
+ // Faster smooth transformation if scaledSize is noticeably smaller than \
m_pixmap + m_scaledPixmap = m_pixmap.scaled(2 * scaledSize)
+ .scaled(scaledSize, Qt::IgnoreAspectRatio, \
Qt::SmoothTransformation); + }
}
+
+ painter->drawPixmap(0, 0, m_scaledPixmap);
}
void AlbumArt::setPixmap(const QPixmap& pixmap)
{
m_pixmap = pixmap;
+ m_scaledPixmap = QPixmap();
if (pixmap.isNull()) {
hide();
updateGeometry();
--- trunk/KDE/kdeplasma-addons/applets/nowplaying/albumart.h #933143:933144
@@ -46,6 +46,7 @@
private:
QPixmap m_pixmap;
+ QPixmap m_scaledPixmap;
};
#endif // ALBUMART_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic