BigRedButtonOfDeath.WPF.Extensions.ToBitmapSource C# (CSharp) Method

ToBitmapSource() static public method

static public ToBitmapSource ( this bitmap ) : System.Windows.Media.Imaging.BitmapSource
bitmap this
return System.Windows.Media.Imaging.BitmapSource
        static public BitmapSource ToBitmapSource(this System.Drawing.Bitmap bitmap)
        {
            BitmapSource bm = null;
            if (bitmap != null)
            {
                IntPtr hBitmap = bitmap.GetHbitmap();
                BitmapSizeOptions sizeOptions = BitmapSizeOptions.FromEmptyOptions();
                bm = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, sizeOptions);
                bm.Freeze();
            }
            return bm;
        }
    }