BitmapImage From Stream - CSharp System.Windows.Media.Imaging

CSharp examples for System.Windows.Media.Imaging:BitmapImage

Description

BitmapImage From Stream

Demo Code


using System.Windows.Media.Imaging;
using System.Reflection;
using System.IO;//  w  w w . j  av a 2s  .  co  m
using System;

public class Main{
        public static BitmapImage FromStream(Stream stream)
        {
            var image = new BitmapImage();
            image.BeginInit();
            image.CacheOption = BitmapCacheOption.OnLoad;
            image.StreamSource = stream;
            image.EndInit();
            return image;
        }
}

Related Tutorials