What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 18508 |  Welcome, Guest!   Register  Login
 Home > Forums > C# > How do I load a bitmap in WPF? ...
Zhang Jingchu

How do I load a bitmap in WPF?

Replies: 1 | Posted by: Zhang Jingchu on 8/2/2012 | Category: C# Forums | Views: 385 | Status: [Member] | Points: 10  


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


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Rajkatie
Rajkatie  
Posted on: 8/2/2012 12:18:58 PM
Level: Silver | Status: [Member] | Points: 25

Refer following link

http://www.i-programmer.info/programming/wpf-workings/520-bitmapimage-and-local-files-.html


Rajesh Patel
MCPD,MS
Brainbench (Asp.Net 4.0 and CSS 3.0)

Zhang Jingchu, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 8:34:08 AM