Arun
Arun

Reputation: 3456

How to resize an image by keeping its aspect ration in Windows phone

I want to resize the image that I am going to display by keeping its aspect ratio.

How can I achieve that. ?

    public MainPage()
    {
        InitializeComponent();

        myImage = new Image();
        Uri uri = new Uri("Penguins.jpg", UriKind.Relative);
        bit = new BitmapImage(uri);

        myImage.Source = bit;
        imagePanel.Children.Add(myImage);
    }

Here the image is stored in the variable bit. How can I resize it by keeping its aspect ratio ?

Thanks.

Upvotes: 2

Views: 875

Answers (1)

Ku6opr
Ku6opr

Reputation: 8126

There is a Stretch property in Image class. You can set None, Uniform or UniformToFill to keep aspect ratio when image is resized in order to fill image area

Upvotes: 2

Related Questions