aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickimagebase.cpp
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2015-01-15 13:38:40 +0100
committerMorten Johan Sørvig <morten.sorvig@theqtcompany.com>2015-02-13 19:22:39 +0000
commit428b92583ee2102c7ef16776a9b7785df7ff4e2c (patch)
treec04e51093d4eb31ea248a035deb52c66d265a576 /src/quick/items/qquickimagebase.cpp
parent5b31071e56ef6e241e27b66ff91f4e9222f2cddb (diff)
High-dpi SVG and QQuickImageProvider Images
Scale sourceSize by the target devicePixelRatio before passing it to the providers. Task-number: QTBUG-38127 Task-number: QTBUG-38991 Change-Id: I1746e0859b4e63eb0d28d1a1c8aac610b68a9eb9 Reviewed-by: Jocelyn Turcotte <jturcotte@woboq.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Diffstat (limited to 'src/quick/items/qquickimagebase.cpp')
-rw-r--r--src/quick/items/qquickimagebase.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/quick/items/qquickimagebase.cpp b/src/quick/items/qquickimagebase.cpp
index c82b019608..688cf57441 100644
--- a/src/quick/items/qquickimagebase.cpp
+++ b/src/quick/items/qquickimagebase.cpp
@@ -209,7 +209,19 @@ void QQuickImageBase::load()
d->devicePixelRatio = 1.0;
QUrl loadUrl = d->url;
- resolve2xLocalFile(d->url, targetDevicePixelRatio, &loadUrl, &d->devicePixelRatio);
+ if (d->url.scheme() == QStringLiteral("image")
+ || d->url.toString().endsWith(".svg") || d->url.toString().endsWith(".svgz")) {
+ // QQuickImageProvider and SVG can generate a high resolution image when
+ // sourceSize is set. If sourceSize is not set then the provider default size
+ // will be used, as usual.
+ if (d->sourcesize.isValid())
+ d->devicePixelRatio = targetDevicePixelRatio;
+ } else {
+ // (possible) local file: loadUrl and d->devicePixelRatio will be modified if
+ // an "@2x" file is found.
+ resolve2xLocalFile(d->url, targetDevicePixelRatio, &loadUrl, &d->devicePixelRatio);
+ }
+
d->pix.load(qmlEngine(this), loadUrl, d->sourcesize * d->devicePixelRatio, options);
if (d->pix.isLoading()) {