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;
}
}