Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

How Do I load a BitmapImage in WPF?

- - - - -

  • Please log in to reply
No replies to this topic

#1
xarzu

xarzu

    Newbie

  • Member
  • 17 posts
  • Joined 05-April 07
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


How to remove advertisement from MSFN



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users