C#调用VC的Dll时遇到的IntPtr类型转化成byte[]的问题
我使用VC写的动态链接库的某函数的接口如下:
AUTOCROPPINGDLL_API int aaa(IN BYTE* pBmpData,
IN int nWidth,
IN int nHeight)
我使用C#重新声明的接口:
[DllImport("xxx.dll", EntryPoint="#4")]
public static extern int aaa(
[MarshalAs(UnmanagedType.LPArray)] byte[] pBmpData,
int nWidth,
int nHeight);
但是当我在bitmap的lockbit并想将bmpData.Scan0作为参数传给接口函数的时候却遇到类型转化错误。
BitmapData实例的Scan0是Intptr类型的,说没办法转化成byte[]类型。请问我该如何将bmpData的Scan0作为参数传给接口函数?