Convert System.Windows.Media.ImageSource to System.Drawing.Bitmap

前端 未结 2 607
庸人自扰
庸人自扰 2020-11-30 14:04

How can I convert a System.Windows.Media.ImageSource to a System.Drawing.Bitmap in C#?

2条回答
  •  眼角桃花
    2020-11-30 14:19

    Please see HOW TO USE IMAGESOURCE (NO HANDLER) IN WINFORMS AS SYSTEM.DRAWING.BITMAP (HBITMAP):

    How to easily convert WinForms System.Drawing.Bitmap into WPF ImageSource you learned from this article. Today, I'll explain how to do it contrary. Actually, all he have to do is to extract handler from BitmapSource, however, such approach is not supported, thus the only thing we can do is just copy pixels of BitmapSource (or BitmapFrame) into byte array and then copy them into the pointer of HBitmap.

提交回复
热议问题