Tech Off Post

Single Post Permalink

View Thread: extending WPF/Avalon/XAML - webcam preview
  • User profile image

    sashah wrote:

        ONly problem im having is converting between a system.drawing.image to a cant find anything on web about it.

    the following code snippet can do the trick:
    System.Drawing.Bitmap GdiBitmap = new System.Drawing.Bitmap(@"c:\temp\sample.jpg");
                            IntPtr hBitmap = bitmap.GetHbitmap();
                            System.Windows.Media.BitmapSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmapbitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                            System.Windows.Controls.Image WpfImage = new System.Windows.Controls.Image();
                            WpfImage.Source = WpfBitmap;