将位图写入HWND(Clarion将HWND传递给.NET DLL)?

时间:2013-07-10 17:38:54

标签: c# .net bitmap hwnd clarion

我正在为Clarion(Clarion是一种C ++类型语言)程序编写.NET DLL。 Clarion程序调用.NET DLL方法将Clarion图像控件的HWND传递给它。在.NET DLL中,我可以从传入的HWND中获得正确的RECT(顶部,右侧,底部,左侧),因此我知道我有正确的HWND。

我似乎无法找到的是在.NET DLL中将位图写入HWND。在Clarion方面,我会这样做:

  

?myImageControl {PROP:ImageBits} = ImageBytes

其中ImageBytes是一个字节数组,例如文件或Clarion STRING(固定长度,不是零终止)。

提前致谢。

1 个答案:

答案 0 :(得分:0)

我想你可以尝试:Graphics.FromHwnd()

Image image = new Bitmap("somefile.bmp");
using (Graphics g = Graphics.FromHwnd(intptrHwnd))
{
    g.DrawImage(image, new Point(0, 0));
}

请参阅:http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromhwnd.aspx