为什么返回值,只有width和height,图像的buf为空?

C++的dll 文件 函数声明
DWORD H264_PLAY_CatchPicBuf(LONG nPort, char* pBuf,LONG len,LONG *width,LONG *height,long ntype=0)

我的C# 导入 函数声明
[DllImport("H264Play.dll")]
public static extern int H264_PLAY_CatchPicBuf(int nPort,ref IntPtr buf,int len, ref int pwidth, ref int pheight,int type=0);

C#程序中的变量定义
public IntPtr ImgBuf = Marshal .AllocHGlobal(928*576*3);
int getc = XMSDK.H264_PLAY_CatchPicBuf(1,ref ImgBuf,928*576*3,ref ImgWidth, ref ImgHeight, 0);

相关的变量,用到的部分就是上面这些

但是返回值,只有width和height,图像的buf为空。

而且调试运行至调用函数这句,报错, (。exe停止运行)

问:1. 我是不是imgbuf定义错了,或使用错了,没有返回值
2.我分配的空间太大导致的 停止运行 报错?

慕容森
浏览 231回答 2
2回答

红颜莎娜

byte[] ImgBuf =new ImgBuf [928*576*3+80];int getc = XMSDK.H264_PLAY_CatchPicBuf(1,ImgBuf,928*576*3+80,ref ImgWidth, ref ImgHeight, 0);

MM们

去掉ref ImgBuf 里的ref
打开App,查看更多内容
随时随地看视频慕课网APP