aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick/util/qquickimageprovider.cpp9
-rw-r--r--tests/auto/quick/qquickimage/tst_qquickimage.cpp6
-rw-r--r--tests/manual/imagehandler/embeddedimage.svg10
-rw-r--r--tests/manual/imagehandler/heart.pngbin0 -> 15194 bytes
-rw-r--r--tests/manual/imagehandler/main.qml6
5 files changed, 27 insertions, 4 deletions
diff --git a/src/quick/util/qquickimageprovider.cpp b/src/quick/util/qquickimageprovider.cpp
index 1a13f6395a..2bb2af4fc0 100644
--- a/src/quick/util/qquickimageprovider.cpp
+++ b/src/quick/util/qquickimageprovider.cpp
@@ -680,15 +680,18 @@ QSize QQuickImageProviderWithOptions::loadSize(const QSize &originalSize, const
return res;
const bool preserveAspectCropOrFit = options.preserveAspectRatioCrop() || options.preserveAspectRatioFit();
+ const bool formatIsSvg = (format == "svg" || format == "svgz");
- if (!preserveAspectCropOrFit && (format == "svg" || format == "svgz") && !requestedSize.isEmpty())
+ if (!preserveAspectCropOrFit && formatIsSvg && !requestedSize.isEmpty())
return requestedSize;
qreal ratio = 0.0;
- if (requestedSize.width() && (preserveAspectCropOrFit || requestedSize.width() < originalSize.width())) {
+ if (requestedSize.width() && (preserveAspectCropOrFit || formatIsSvg ||
+ requestedSize.width() < originalSize.width())) {
ratio = qreal(requestedSize.width()) / originalSize.width();
}
- if (requestedSize.height() && (preserveAspectCropOrFit || requestedSize.height() < originalSize.height())) {
+ if (requestedSize.height() && (preserveAspectCropOrFit || formatIsSvg ||
+ requestedSize.height() < originalSize.height())) {
qreal hr = qreal(requestedSize.height()) / originalSize.height();
if (ratio == 0.0)
ratio = hr;
diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
index 3613ba6d87..d1f46a3912 100644
--- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp
+++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
@@ -445,6 +445,12 @@ void tst_qquickimage::svg()
// Due to aspect ratio calculations we can't get a precise
// check for all setups, so we allow a small margin of error
QVERIFY(qAbs(obj->height() - 141) < 1);
+
+ // Setting it to a size bigger than the actual file, SVG formats
+ // can scale up although other image formats cannot
+ obj->setSourceSize(QSize(800,0));
+ QCOMPARE(obj->width(), 800.0);
+ QVERIFY(qAbs(obj->height() - 1131) < 1);
delete obj;
}
diff --git a/tests/manual/imagehandler/embeddedimage.svg b/tests/manual/imagehandler/embeddedimage.svg
new file mode 100644
index 0000000000..f952640822
--- /dev/null
+++ b/tests/manual/imagehandler/embeddedimage.svg
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.2" baseProfile="tiny">
+
+ <desc>This document has a reference to an external image</desc>
+
+ <image x="200" y="200" width="100" height="100" xlink:href="heart.png">
+ <title>External image</title>
+ </image>
+</svg>
diff --git a/tests/manual/imagehandler/heart.png b/tests/manual/imagehandler/heart.png
new file mode 100644
index 0000000000..deaec18274
--- /dev/null
+++ b/tests/manual/imagehandler/heart.png
Binary files differ
diff --git a/tests/manual/imagehandler/main.qml b/tests/manual/imagehandler/main.qml
index 55e5b89cae..ec474e62ce 100644
--- a/tests/manual/imagehandler/main.qml
+++ b/tests/manual/imagehandler/main.qml
@@ -41,6 +41,10 @@ Window {
width: parent.width
sourceSize.height: height
sourceSize.width: width
+ MouseArea {
+ anchors.fill: parent
+ onClicked: svgImage.source = "embeddedimage.svg"
+ }
}
ListModel {
id: imageFillModeModel
@@ -57,7 +61,7 @@ Window {
height: 75
anchors.bottom: parent.bottom
Text {
- text: "Click the options below to change the fill mode"
+ text: "Click the options below to change the fill mode.<br>Click the image to change the used image."
font.pointSize: 16
}