【发布时间】:2011-04-04 09:23:34
【问题描述】:
有没有办法将 System.Windows.Interop.InteropBitmap 转换为 System.Drawing.Bitmap?
谢谢
【问题讨论】:
有没有办法将 System.Windows.Interop.InteropBitmap 转换为 System.Drawing.Bitmap?
谢谢
【问题讨论】:
我能够使用下面的代码解决我的问题。 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);
【讨论】:
您可以使用 CopyPixels 获取像素,并使用来自the Bitmap.Lock/Unlock documentation 的代码将像素传递给位图。
【讨论】:
您能否再解释一下问题的背景? InteropBitmap 不是要在 WPF 中呈现旧的位图元素吗?好像你正试图从 win32 -> WPF -> win32 去。
【讨论】: