X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FWPF%2FBitmapSourceConverter.cs;fp=Parasitemia%2FWPF%2FBitmapSourceConverter.cs;h=0000000000000000000000000000000000000000;hb=95f9edf71456c8bf89a91850800f66efc2c9d4da;hp=413a53bb93ca86b2c5389354ab560bf30c5646c2;hpb=d247f3a07ca3c7b192d8c2381ea85ba731fcc359;p=master-thesis.git diff --git a/Parasitemia/WPF/BitmapSourceConverter.cs b/Parasitemia/WPF/BitmapSourceConverter.cs deleted file mode 100644 index 413a53b..0000000 --- a/Parasitemia/WPF/BitmapSourceConverter.cs +++ /dev/null @@ -1,47 +0,0 @@ -//---------------------------------------------------------------------------- -// Copyright (C) 2004-2015 by EMGU Corporation. All rights reserved. -//---------------------------------------------------------------------------- - -using System; -using System.Runtime.InteropServices; -using System.Windows; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; -using Emgu.CV; - -namespace Emgu.CV.WPF -{ - public static class BitmapSourceConvert - { - /// - /// Delete a GDI object - /// - /// The poniter to the GDI object to be deleted - /// - [DllImport("gdi32")] - private static extern int DeleteObject(IntPtr o); - - /// - /// Convert an IImage to a WPF BitmapSource. The result can be used in the Set Property of Image.Source - /// - /// The Emgu CV Image - /// The equivalent BitmapSource - public static BitmapSource ToBitmapSource(IImage image) - { - using (System.Drawing.Bitmap source = image.Bitmap) - { - IntPtr ptr = source.GetHbitmap(); //obtain the Hbitmap - - BitmapSource bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( - ptr, - IntPtr.Zero, - Int32Rect.Empty, - System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); - - DeleteObject(ptr); //release the HBitmap - return bs; - } - } - } -} \ No newline at end of file