我正在尝试使用托管代码中的非托管代码
我想从非托管代码中提供以下函数
extern "C" __declspec( dllexport) HBITMAP * DetectDocumentPatter(HBITMAP* b);
现在代码的实现只返回相同的参数b
我正试图从.net端访问它
1 Bitmap b = new Bitmap(@"C:\Projects\samples\9b.jpg");
2 Rectangle rect = new Rectangle(0, 0, b.Width, b.Height);
3 BitmapData bmpData = b.LockBits(rect, ImageLockMode.ReadWrite, b.PixelFormat);
4 IntPtr p = wrapper.DetectDocumentPatter(bmpData.Scan0);
5 Bitmap c = Bitmap.FromHbitmap(p);
6 c.Save(@"C:\Projects\samples\unmanagedBitmap.jpg");
但第5行代码通过GDI +
中发生的一般错误任何想法我如何将HBITMAP编组到.net位图! 我在这里搜索,但内容真的很误导