petko_stankoski
petko_stankoski

Reputation: 10723

Image.FromStream() in C#

I work in VS 2010, .Net 4.0. In Windows forms app, this is ok:

Image img = Image.FromStream(imagePart.GetStream());

However, in Wpf app, the Image class is from System.Windows.Controls and that isn't valid because it hasn't got a definition for FromStream method. In Windows forms, the Image class is System.Drawing.Image.

Is there a way I can use FromStream in Wpf app?

Upvotes: 3

Views: 6302

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1503649

In WPF I believe you'd use a BitmapSource such as BitmapImage - and in the latter case, you can set the StreamSource property to the appropriate stream.

EDIT: BitmapSource is just one subclass of ImageSource. Use a source by creating an Image control and setting the Source property.

Upvotes: 6

Related Questions