Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shrinking Images rather than Stretching

Tags:

wpf

I am having a little trouble in WPF - I am fully aware of the image stretch function and how to use it, and have that working fine. What I am trying to do however, is only apply the stretch if the image is too large (essentially to make it a shrink), and retain the original size if the image would fit into the view. The stretch method currently performs the shrinking perfectly, but will expand smaller images to fill the view which is not what I am after.

Is there a simple way of doing this?

like image 499
Rob Avatar asked May 09 '11 11:05

Rob


People also ask

What is the difference between stretching and resizing?

Similarly, when you stretch an image to make it bigger, the pixels of the image is destroyed, and you see the picture blur — on the other hand, resizing increase the size of the picture by amending the pixels of the image. So, when you resize the photo into its large size, you see the same photo without any blurriness.

How do I change the size of an image in Photoshop without stretching it?

The Constrain Proportions option lets you maintain the aspect ratio (the ratio of image width to image height). If you select this option and change the image size and resolution, the image does not stretch or shrink. The Resample Image option lets you change the size of an image without changing the resolution.


1 Answers

you have to use the StretchDirection property in conjunction with the Stretch Property:

image.StretchDirection = StretchDirection.DownOnly; 
like image 102
David Avatar answered Sep 30 '22 10:09

David