如何解决C#DirectX绘图位图
我有一个附加到另一个进程的c#控制台应用程序。要使用该库,请使用https://github.com/lolp1/Overlay.NET这个库。在处理所有图形的脚本中,我可以这样调用位图绘制方法:
overlay.Graphics.DrawImage();
在Direct2DRenderer脚本中,需要创建函数。例如这样的
public void BorderedRectangle(float x,float y,int width,int height,float stroke,float borderStroke,int brush,int borderBrush) {
_device.DrawRectangle(
new RawRectangleF(x - (stroke - borderStroke),y - (stroke - borderStroke),x + width + stroke - borderStroke,y + height + stroke - borderStroke),_brushContainer[borderBrush],borderStroke);
_device.DrawRectangle(new RawRectangleF(x,y,x + width,y + height),_brushContainer[brush],stroke);
_device.DrawRectangle(
new RawRectangleF(x + (stroke - borderStroke),y + (stroke - borderStroke),x + width - stroke + borderStroke,y + height - stroke + borderStroke),borderStroke);
}
但是当我试图创建一个绘制位图的函数时,一旦覆盖层被加载,我的应用程序就会崩溃。为了绘制位图,我尝试了以下方法:
System.Drawing.Bitmap tempB = new System.Drawing.Bitmap(path);
unsafe {
TypedReference bm = __makeref(tempB);
IntPtr ptr = **(IntPtr**)&bm;
_device.DrawBitmap(new Bitmap(ptr),opacity,BitmapInterpolationMode.Linear);
}
}
我还尝试了其他一些方法来创建SharpDX.Direct2D1位图,但它们都以相同的结果结束。
有人知道如何绘制位图吗?
对不起,我的英语水平不是最好。但是谢谢您的帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。