Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF:System.Windows.Interop.InteropBitmap到System.Drawing.Bitmap_Wpf_C# 4.0_Interop_Bitmap - Fatal编程技术网

WPF:System.Windows.Interop.InteropBitmap到System.Drawing.Bitmap

WPF:System.Windows.Interop.InteropBitmap到System.Drawing.Bitmap,wpf,c#-4.0,interop,bitmap,Wpf,C# 4.0,Interop,Bitmap,是否有方法将System.Windows.Interop.InteropBitmap转换为System.Drawing.Bitmap 谢谢您可以使用CopyPixels获取像素,并使用中的代码将像素传递到位图。您可以进一步解释问题的背景吗?InteropBitmap不是要在WPF中呈现遗留位图元素吗?似乎您正在尝试从win32->WPF->win32开始。我可以使用下面的代码解决我的问题。msg.ThumbnailSource包含对象的System.Windows.Interop.Interop

是否有方法将System.Windows.Interop.InteropBitmap转换为System.Drawing.Bitmap


谢谢

您可以使用CopyPixels获取像素,并使用中的代码将像素传递到位图。

您可以进一步解释问题的背景吗?InteropBitmap不是要在WPF中呈现遗留位图元素吗?似乎您正在尝试从win32->WPF->win32开始。我可以使用下面的代码解决我的问题。msg.ThumbnailSource包含对象的System.Windows.Interop.InteropBitmap类型

BitmapSource bmpSource = msg.ThumbnailSource as BitmapSource;
MemoryStream ms = new MemoryStream();
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bmpSource));
encoder.Save(ms);
ms.Seek(0, SeekOrigin.Begin);


System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(ms);