bookmark - How Do I Load A Bitmapimage In Wpf?

How Do I Load A Bitmapimage In Wpf?

 
 Discussion by xarzu with 0 Replies.
 Last Update: August 3, 2012, 1:00 am
 
bookmark - How Do I Load A Bitmapimage In Wpf?  
    
free web hosting
 
In a silverlight app, I have a BitmapImage defined as System.Windows.Media.Imaging.BitmapImage and it as a method called "SetSource" where I can set the source like this:

CODE

BitmapImage bitmap = new BitmapImage();
System.IO.Stream stream = _scene.GetStream();
if (stream == null) return;
bitmap.SetSource(stream);

In a WPF application I have also have a Bitmap image defined as System.Windows.Media.Imaging.BitmapImage but there is no SetSource method. How do I set the source in a WPF app like I do in a Silverlight app?
Also, it is a stream, not a string. It is not a URI. so "UriSource" method does not work. I tried this:

CODE

System.IO.Stream stream = _scene.GetStream();
if (stream == null) return;
BitmapImage bitmap = new BitmapImage();


bitmap.UriSource = new Uri(stream.ToString());
And at runtime, it threw an error tha URI cannot be determined. Is the URI an identifier for the intranet? Are you sure that this is not a silverlight thing? I am doing a WPF application

Fri Aug 3, 2012    Reply    New Discussion   


Quickly Post to How Do I Load A Bitmapimage In Wpf?  w/o signup Share Info about How Do I Load A Bitmapimage In Wpf?  using Facebook, Twitter etc. email your friend about How Do I Load A Bitmapimage In Wpf? Print
Reply / Comment Ask a Question? Share / Bookmark E-Mail a Friend Print

How Do You Set A Default Size Of A Control That You Can Resize?   How Do You Set A Default Size Of A Control That You Can Resize? (0)