Beispiel #1
0
 public static BitmapSource BitmapToBitmapSource(System.Drawing.Bitmap bitmap)
 {
     try
     {
         IntPtr ptr = bitmap.GetHbitmap();
         BitmapSource result = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ptr, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
         DeleteObject(ptr);
         return result;
     }
     catch
     {
         return null;
     }
 }