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?
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.
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.
you have to use the StretchDirection property in conjunction with the Stretch Property:
image.StretchDirection = StretchDirection.DownOnly;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With