locked
How to preserve a large image without any stretching? RRS feed

  • Question

  • When an image's size exceeds that of its container, it is cropped if the stretch mode is "None".  A xaml code example is the following:

    <Border>
        <Image Stretch="None" Source="VeryLargeImage.png"/>
    </Border>

    Since it is already cropped, TranslateTransform cannot be used to move blocked parts into the viewable area.  Is there a way to preserve the original image without any stretching and cropping?


    Hong

    Tuesday, December 24, 2013 3:43 PM

All replies

  • Hi,

    If you set the value of the Stretch property to None andcontainer is not already using explicitly set values for the Height and/or Width property, the image always retains its natural size without any cropped and stretch. You can refer to the link and see the Remarks in it:

    http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.image.stretch.aspx

    Best Wishes!



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    • Edited by Anne Jing Wednesday, December 25, 2013 2:01 AM edit
    Wednesday, December 25, 2013 2:01 AM
  • Hi Anne,

    It is exactly the what I did, and the image was cropped.

    Here is a quote from this MSDN page:

    • None: The image doesn't stretch to fill the output dimensions. Be careful with this Stretch setting: if the source image is larger than the containing area, your image will be clipped, and this usually isn't desirable because you don't have any control over the viewport like you do with a deliberate Clip.


    Hong

    Wednesday, December 25, 2013 2:15 AM