开发者

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

Is there a way to co开发者_高级运维nvert System.Windows.Interop.InteropBitmap to System.Drawing.Bitmap?

Thank you


I was able to solve my problem using the code below. msg.ThumbnailSource contains System.Windows.Interop.InteropBitmap type of object

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);


You could take the pixels using CopyPixels and use the code from the Bitmap.Lock/Unlock documentation to pass the pixels to the Bitmap.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜