Hi,
I am trying to do a simple thing but I can't ...
I just want to get a BitmapImage from a internet URL, but my function doesn't seem to work properly, it only return me a small part of the image. I know WebResponse are working async and that's certainly why I have this problem, but how can I do it synchronously ?
Here is my function :
internal static BitmapImage GetImageFromUrl(string url)
{
Uri urlUri = new Uri(url);
WebRequest webRequest = WebRequest.CreateDefault(urlUri);
webRequest.ContentType = "image/jpeg";
WebResponse webResponse = webRequest.GetResponse();
BitmapImage image = new BitmapImage();
image.BeginInit();
image.StreamSource = webResponse.GetResponseStream();
image.EndInit();
return image;
}
Thank a lot for your help.