Go Back   GIDForums > Computer Programming Forums > .NET Forum
User Name
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
Thread Tools Search this Thread Rate Thread
Old 03-Aug-2012, 09:38
complete's Avatar
complete complete is offline
New Member
Join Date: Aug 2005
Posts: 15
complete is on a distinguished road

How do you load a bitmapimage in wpf?

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
Old 27-Oct-2015, 01:21
lindseynicole lindseynicole is offline
New Member
Join Date: Oct 2015
Posts: 13
lindseynicole has a little shameless behaviour in the past

Re: How do you load a bitmapimage in wpf?

var uri = new Uri("pack://application:,,,/sas.png"); var bitmap = new BitmapImage(uri); image1.Source = bitmap;
Old 05-Dec-2017, 16:24
neckozenica neckozenica is offline
New Member
Join Date: Nov 2017
Posts: 14
neckozenica is on a distinguished road

Re: How do you load a bitmapimage in wpf?


maybe this can help :

src.BeginInit(); src.UriSource = new Uri("picture.jpg", UriKind.Relative); src.CacheOption = BitmapCacheOption.OnLoad; src.EndInit();

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Load balancer worker status gogineni Apache Web Server Forum 0 11-Apr-2011 11:56
Load flash movies directly from any source (no temporary files)+snap a frame Ann .NET Forum 0 25-Feb-2011 00:04
How to load content with php? dada78 MySQL / PHP Forum 12 07-Sep-2004 07:00
why didnt XP load TCPIP.SYS file? vsseym Computer Software Forum - Windows 0 28-Jul-2004 07:33
Unable to load any games after BIOS update lizard- Computer Hardware Forum 6 07-Jan-2004 09:23

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:38.

vBulletin, Copyright © 2000 - 2018, Jelsoft Enterprises Ltd.