110,561
社区成员
发帖
与我相关
我的任务
分享
// SDKAPI.VCAPauseCapture(0);
SnapOk = false;
RecOk = 0;
haha = "nwidth" + nWidth + "height:" + nHeight;
SDKAPI.CaptureFileAsBmp(StrPicPath, pbuff, rgb24, 600, 400);
在执行这个的时候 提示
尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
他原来这个sdk是c++ 的 不太懂
BOOL __declspec(dllimport) CaptureFileAsBmp(LPCTSTR szFileName,
BYTE *pYUVBuffer,
BYTE *pRGBBuffer,
long nWidth,
long nHeight);
原型是这样 不晓得*pYUVBuffer,*pRGBBuffer该怎么替换
string StrPicPath;
DateTime CurTime = DateTime.Now;
StrPicPath = "d:\\" + CurTime.ToString("yyyyMMddHHmmss") + "Camera0" + ".bmp";
IntPtr rgb24 = new IntPtr(600 * 400 * 3);
SDKAPI.CaptureFileAsBmp(StrPicPath, pbuff, rgb24, 600, 400);
你就直接调用SDKAPI.CaptureFileAsBmp()函数进行截图试试。 DateTime CurTime = DateTime.Now;
string imgpath = "d:\\" + CurTime.ToString("yyyyMMddHHmmss");
SDKAPI.VCASaveAsJpegFile(0, imgpath + "dib1top.jpg", 100);
sdk 提供的函数 没有设置宽高的参数
他倒是还有一种回调的函数 截图设置
但是程序运行过程中 执行不到这个
SDKAPI.PrcVidCapCallBack SnapCall = new SDKAPI.PrcVidCapCallBack(snapcallback);
//Register the capture stream callback
SDKAPI.VCARegVidCapCallBack(0, SnapCall);
snapcallback函数
//snap callback 拍照的事件
public static void snapcallback(int dwCard, IntPtr pbuff, int dwSize)
{
if (SnapOk == true)
{
string StrPicPath;
DateTime CurTime = DateTime.Now;
StrPicPath = "d:\\" + CurTime.ToString("yyyyMMddHHmmss") + "Camera0" + ".bmp";
IntPtr rgb24 = new IntPtr(600 * 400 * 3);
SDKAPI.CaptureFileAsBmp(StrPicPath, pbuff, rgb24, 600, 400);
// SDKAPI.VCAPauseCapture(0);
SnapOk = false;
RecOk = 0;
haha = "nwidth" + nWidth + "height:" + nHeight;
}
}