MSFN Forum: How Do I load a BitmapImage in WPF? - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How Do I load a BitmapImage in WPF? Rate Topic: -----

#1 User is offline   xarzu 

  • Newbie
  • Group: Members
  • Posts: 17
  • Joined: 05-April 07

Posted 03 August 2012 - 08:40 AM

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:
	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:
 
        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


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy