如何在WPF中使用GDI +绘图? [英] How to use the GDI+ drawing in WPF?

查看:678
本文介绍了如何在WPF中使用GDI +绘图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的WPF控件中使用GDI +绘图。

I want to use the GDI+ drawing in my WPF control.

推荐答案

有几种方法可以做到这一点,最简单将锁定您使用GDI操作的位图,获取像素缓冲区(Scan0 IntPtr位于从锁中获取的BitmapData中)。从您的像素缓冲区 CopyMemory(...) WriteableBitmap.BackBuffer

There are several ways to do this, the easiest would be to lock your Bitmap you manipulated with GDI, get the pixel buffer (Scan0 IntPtr in the BitmapData you get from the lock). CopyMemory(...) from you pixel buffer to a WriteableBitmap.BackBuffer.

WPF中有更多高性能的方式,如使用InteropBitmap而不是WriteableBitmap。但是这需要更多的p / invoke。

There are more performant ways in WPF, like using the InteropBitmap instead of WriteableBitmap. But that needs more p/invoke.

这篇关于如何在WPF中使用GDI +绘图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆