diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-03-17 07:10:56 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2011-03-17 07:17:43 (GMT) |
commit | 695a39410c8ce186a2ce78cef51093c55fc32643 (patch) | |
tree | b33d7c5f1f0e24b1180fcbdb989a47e38f825868 /src/declarative/graphicsitems/qdeclarativeimage.cpp | |
parent | cb0b93e3ef107b8a47445c926753b6bcf07b796d (diff) | |
download | Qt-695a39410c8ce186a2ce78cef51093c55fc32643.zip Qt-695a39410c8ce186a2ce78cef51093c55fc32643.tar.gz Qt-695a39410c8ce186a2ce78cef51093c55fc32643.tar.bz2 |
Image.PreserveAspectFit has unexpected effect on Image's sourceSize
The sourceSize should always be the size of the image, unless set
otherwise. When calculating the size of an image with
Image.PreserveAspectFit set the natural image size should be used
for the calculation if no size has been set explicitly.
Change-Id: I104b7d1c3c16aa5b4fc98b1f9078ed8ae997cf69
Task-number: QTBUG-16389
Reviewed-by: Joona Petrell
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativeimage.cpp')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeimage.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index ec20200..ed5d5fc 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -389,14 +389,16 @@ void QDeclarativeImage::updatePaintedGeometry() if (d->fillMode == PreserveAspectFit) { if (!d->pix.width() || !d->pix.height()) return; - qreal widthScale = width() / qreal(d->pix.width()); - qreal heightScale = height() / qreal(d->pix.height()); + qreal w = widthValid() ? width() : d->pix.width(); + qreal widthScale = w / qreal(d->pix.width()); + qreal h = heightValid() ? height() : d->pix.height(); + qreal heightScale = h / qreal(d->pix.height()); if (widthScale <= heightScale) { - d->paintedWidth = width(); + d->paintedWidth = w; d->paintedHeight = widthScale * qreal(d->pix.height()); } else if(heightScale < widthScale) { d->paintedWidth = heightScale * qreal(d->pix.width()); - d->paintedHeight = height(); + d->paintedHeight = h; } if (widthValid() && !heightValid()) { setImplicitHeight(d->paintedHeight); |