Search code examples
c#.netimagebitmapbitmapsource

How to share pixel data between Bitmap and Bitmapsource without a reallocation?


Is it possible to create a System.Windows.Media.Imaging.Bitmapsource from a System.Drawing.Bitmap without a reallocation? Unfortunately all methods described in other post included a copy of the pixel data which is not always needed and very expensive...


Solution

  • I found this solution and it worked perfectly for me!

    WpfImage.Source = new SharedBitmapSource(DrawingBitmap);