diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-08-11 01:51:08 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-08-11 01:51:08 (GMT) |
commit | 712b8ecad2407645ef80fef94181782d2227b002 (patch) | |
tree | 32f60895171a18ae69723e1ee5835bdb878cd667 /src/declarative/fx/qfximage.cpp | |
parent | 8c3405bbf65826f0ab0be0bd090d723f8efaa3af (diff) | |
parent | 2b9be8a7e00405626664dc9d21cd59e236b899a8 (diff) | |
download | Qt-712b8ecad2407645ef80fef94181782d2227b002.zip Qt-712b8ecad2407645ef80fef94181782d2227b002.tar.gz Qt-712b8ecad2407645ef80fef94181782d2227b002.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/fx/qfximage.cpp')
-rw-r--r-- | src/declarative/fx/qfximage.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 0cb7988..ec3fdab 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -176,13 +176,15 @@ void QFxImage::setPixmap(const QPixmap &pix) \list \o Stretch - the image is scaled to fit - \o PreserveAspect - the image is scaled uniformly to fit + \o PreserveAspectFit - the image is scaled uniformly to fit without cropping + \o PreserveAspectCrop - the image is scaled uniformly to fill, cropping if necessary \o Tile - the image is duplicated horizontally and vertically \o TileVertically - the image is stretched horizontally and tiled vertically \o TileHorizontally - the image is stretched vertically and tiled horizontally \endlist \image declarative-image_fillMode.gif + \sa examples/declarative/fillmode \sa examples/declarative/aspectratio */ QFxImage::FillMode QFxImage::fillMode() const @@ -301,7 +303,7 @@ void QFxImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) QTransform scale; - if (d->fillMode == PreserveAspect) { + if (d->fillMode == PreserveAspectFit) { if (widthScale < heightScale) { heightScale = widthScale; scale.translate(0, (height() - heightScale * pix.height()) / 2); @@ -309,6 +311,14 @@ void QFxImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) widthScale = heightScale; scale.translate((width() - widthScale * pix.width()) / 2, 0); } + } else if (d->fillMode == PreserveAspectCrop) { + if (widthScale < heightScale) { + widthScale = heightScale; + scale.translate((width() - widthScale * pix.width()) / 2, 0); + } else if(heightScale < widthScale) { + heightScale = widthScale; + scale.translate(0, (height() - heightScale * pix.height()) / 2); + } } scale.scale(widthScale, heightScale); |