diff options
Diffstat (limited to 'examples/declarative/aspectratio/scale_and_crop.qml')
-rw-r--r-- | examples/declarative/aspectratio/scale_and_crop.qml | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/declarative/aspectratio/scale_and_crop.qml b/examples/declarative/aspectratio/scale_and_crop.qml new file mode 100644 index 0000000..283e24b --- /dev/null +++ b/examples/declarative/aspectratio/scale_and_crop.qml @@ -0,0 +1,20 @@ +import Qt 4.6 + +// Here, we implement "Scale and Crop" behaviour. +// +Rectangle { + // default size: whole image, unscaled + width: face.width + height: face.height + color: "gray" + clip: true + + Image { + id: face + smooth: true + source: "pics/face.png" + x: (parent.width-width*scale)/2 + y: (parent.height-height*scale)/2 + scale: Math.max(parent.width/width,parent.height/height) + } +} |