Take the 2-minute tour ×

My application receives a jpeg file as a MemoryStream from a webservice. I need assign the image to image.Source. How can this be done?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

In here it is described:

void proxy_GetImageCompleted(object sender, GetImageCompletedEventArgs e)
    MemoryStream stream = new MemoryStream(e.Result);
    BitmapImage b = new BitmapImage();
    imgImage.Source = b;
share|improve this answer
add comment

The System.Windows.Controls.Image.Source property is of type System.Windows.Media.ImageSource A System.Windows.Media.Imaging.BitmapImage is derived from ImageSource.

And BitmapImage has a SetSource(Stream streamsource) method.

So with the following code you can add an image from a stream:

Stream inStream = [your MemoryStream];

BitmapImage tempImage = new BitmapImage();

YourControlsImage.Source = tempImage;

MSDN links:

Image.Source Property

BitmapSource.SetSource Method

BitmapImage Class

share|improve this answer
add comment

Your Answer


