Update obsolete contact address.
[profile/ivi/qtdeclarative.git] / src / qtquick1 / graphicsitems / qdeclarativeimage.cpp
index 89df7ab..809d373 100644 (file)
@@ -1,8 +1,8 @@
 /****************************************************************************
 **
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
 **
 ** This file is part of the QtDeclarative module of the Qt Toolkit.
 **
@@ -76,7 +76,7 @@ QT_BEGIN_NAMESPACE
 
     The following example shows the simplest usage of the Image element.
 
-    \snippet doc/src/snippets/declarative/image.qml document
+    \snippet doc/src/snippets/qtquick1/image.qml document
 
     \beginfloatleft
     \image declarative-qtlogo.png
@@ -446,7 +446,22 @@ void QDeclarative1Image::geometryChanged(const QRectF &newGeometry, const QRectF
 QRectF QDeclarative1Image::boundingRect() const
 {
     Q_D(const QDeclarative1Image);
-    return QRectF(0, 0, qMax(d->mWidth, d->paintedWidth), qMax(d->mHeight, d->paintedHeight));
+    QRectF boundingRect(0, 0, qMax(d->mWidth, d->paintedWidth), qMax(d->mHeight, d->paintedHeight));
+
+    if (d->fillMode == PreserveAspectCrop) {
+        if (!d->pix.width() || !d->pix.height())
+            return boundingRect;
+        qreal widthScale = width() / qreal(d->pix.width());
+        qreal heightScale = height() / qreal(d->pix.height());
+        if (widthScale < heightScale) {
+            widthScale = heightScale;
+            boundingRect.moveTo((width() - widthScale * d->pix.width()) / 2, 0);
+        } else if (heightScale < widthScale) {
+            heightScale = widthScale;
+            boundingRect.moveTo(0, (height() - heightScale * d->pix.height()) / 2);
+        }
+    }
+    return boundingRect;
 }
 
 /*!