diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-07-21 07:21:49 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-07-21 07:21:49 (GMT) |
commit | c301d995c646c70f8f943e2e4fc293a3e2d29edf (patch) | |
tree | ec5a48981b76879b4dd822e09bd49784bca87b27 /src/declarative | |
parent | bd25c0401644e1a1f443532c3e2a75201422b255 (diff) | |
download | Qt-c301d995c646c70f8f943e2e4fc293a3e2d29edf.zip Qt-c301d995c646c70f8f943e2e4fc293a3e2d29edf.tar.gz Qt-c301d995c646c70f8f943e2e4fc293a3e2d29edf.tar.bz2 |
Add some (disabled) test code for limiting image size.
QFxImage et al could benefit from a limit feature, especially
for remote images.
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/fx/qfxpixmap.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/declarative/fx/qfxpixmap.cpp b/src/declarative/fx/qfxpixmap.cpp index ac8a701..e4d79f4 100644 --- a/src/declarative/fx/qfxpixmap.cpp +++ b/src/declarative/fx/qfxpixmap.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qfxpixmap.h" +#include <QImageReader> #include <QHash> #include <QNetworkReply> #include <QPixmapCache> @@ -124,8 +125,30 @@ QFxPixmap::QFxPixmap(const QUrl &url) if ((*iter)->reply->error()) { qWarning() << "Network error loading" << url << (*iter)->reply->errorString(); } else { + QImageReader imgio((*iter)->reply); + +//#define QT_TEST_SCALED_SIZE +#ifdef QT_TEST_SCALED_SIZE + /* + Some mechanism is needed for loading images at a limited size, especially + for remote images. Loading only thumbnails of remote progressive JPEG + images can be efficient. (Qt jpeg handler does not do so currently) + */ + + QSize limit(60,60); + QSize sz = imgio.size(); + if (sz.width() > limit.width() || sz.height() > limit.height()) { + sz.scale(limit,Qt::KeepAspectRatio); + imgio.setScaledSize(sz); + } +#endif + QImage img; - if (img.load((*iter)->reply, 0)) { + if (imgio.read(&img)) { +#ifdef QT_TEST_SCALED_SIZE + if (!sz.isValid()) + img = img.scaled(limit,Qt::KeepAspectRatio); +#endif d->pixmap = QPixmap::fromImage(img); QPixmapCache::insert(key, d->pixmap); } else { |