|
Hello
I'm working on a little slideshow app for a bigger project where I'm creting a BitmapImage from an URL and feeding it to and ImageElement
The Image element sits inside a ViewBox with a couple of other elements so they resize themselves according to the window size. Anyway that is not importent, what is importning is that I need to be sure that the images does not resize bigger than their original size.
The BitmapImage class have the PixelWidth and PixelHeight which I've tried to use, but they seem to return 1 resulting in a VERY small image. This is what I do
BitmapImage img = new BitmapImage();
img.BeginInit();
img.UriSource = new Uri( node.GetAttribute( "Url" ) );
img.EndInit();
MyImage.Source = img;
MyImage.MaxWidth = img.PixelWidth;
MyImage.MaxHeight = img.PixelHeight;
I've tried moving where is set the MaxHeigt and MaxWidth properties around a bit, but the result is the same a very small image. I succeded getting the Height and Width using the Image class and getting getting the image from a stream but can't use an Image on ImageSource. And loading the image twice is just plain stupid :o)
So my question is how do i get the PixelWidth and Height from a BitmapImage, am i missing something?
--
Christian
|