Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Find out width and height of an Image in C#

I am currently trying to get the Size and reshape my rectangle to the actual size of the image (width and height). However when i use Image.Height or Image.Width its always 0. The picture that is displayed when i start the program takes up the entire screen

            Uri imageUri = new Uri(FileListe[position]);
            Image Bild = new Image();
            Bild.Source = new BitmapImage(imageUri);

            Interface.Width = Bild.Width; 
            Interface.Height = Bild.Height;

            brush.ImageSource = new BitmapImage(imageUri);

            Interface.Fill = brush;

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

have you tried using the bitmap image to get width and height from?

For example:

BitmapImage bitmapBild = new BitmapImage(imageUri);
Interface.Width = bitmapBild.Width;
Interface.Height = bitmapBild.Height;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading