将 Pen 转换为 IntPtr
有没有一种简单的方法可以将 System.Drawing.Pen 转换为其非托管对应项?就像,如果你有一支像这样的笔:
Pen p = new Pen(Color.Blue, 1f);
IntPtr ptr = p.ToPtr();
我知道这段代码不起作用,但是有没有办法类似地做到这一点?
Is there a simple way to convert a System.Drawing.Pen into its unmanaged counterpart? Like, if you had a Pen like this:
Pen p = new Pen(Color.Blue, 1f);
IntPtr ptr = p.ToPtr();
I know this code doesn't work, but is there a way to do it similarly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Pen
类有一个内部属性NativePen
,其中包含您想要的内容。您可以通过反射访问此属性(如果您的代码具有适当的权限):请注意,理论上这可能在 .NET-Framework 的未来版本中不起作用,因为内部属性可能会更改...
The
Pen
class has an internal propertyNativePen
which contains exactly what you want. You can access this property through reflection (if your code has the appropriate permissions) using:Be aware that theoretically this might not work in future versions of the .NET-Framework, since internal properties could change ...