How do I "force load" a BitmapImage so I can access the PixelWidth/Height without involving an Image class instance?
Saturday, April 07, 2012 2:01 AM
I am loading a packaged bitmap:
BitmapImage bitmapImage = new BitmapImage(new Uri(@"ms-appx:///Image.png"));
I want to get the PixelWidth and PixelHeight of the BitmapImage, but I noticed that they are alwasy 0, unless I assign it to an instance of the Image class:
Image = new Image();
Image.Source = bitmapImage;
After the above line, I am able to get the appropriate PixelWidth and PixelHeight values.
Is there a way for me to achieve the same thing without creating Image instances?
Henry = ]
Saturday, April 07, 2012 3:59 AM
I think you don't need to load the entire image at all and instead use the property system. Look at:
- Marked As Answer by Henry Tsai Saturday, April 07, 2012 8:29 AM
Saturday, April 07, 2012 8:32 AM
Thanks! As you suggested, using the code below gets me what I wanted!
ImageProperties imageProperties = await imageFile.Properties.GetImagePropertiesAsync();
Henry = ]
Saturday, December 29, 2012 5:44 PM
I'm downloading the Image from a Uri from internet, not accesing the image from the local storage, so i cannot use ImageProperties... Any other idea to forcé the image to be downloaded and so the widht and height attributes can be accessed? Thanks!
Fernando Urkijo Cereceda