c#的调用语句
private void btnJPEG_Click(object sender, EventArgs e)
{
int lChannel = iChannelNum[(int)iSelIndex]; //通道号 Channel number
CHCNetSDK.NET_DVR_JPEGPARA lpJpegPara = new CHCNetSDK.NET_DVR_JPEGPARA();
lpJpegPara.wPicQuality = 0; //图像质量 Image quality
lpJpegPara.wPicSize = 0xff; //抓图分辨率 Picture size: 0xff-Auto(使用当前码流分辨率)
//抓图分辨率需要设备支持,更多取值请参考SDK文档
//JPEG抓图保存成文件 Capture a JPEG picture
string sJpegPicFileName;
sJpegPicFileName = "filetest.jpg";//图片保存路径和文件名 the path and file name to save
if (!CHCNetSDK.NET_DVR_CaptureJPEGPicture(m_lUserID, lChannel, ref lpJpegPara, sJpegPicFileName))
{
iLastErr = CHCNetSDK.NET_DVR_GetLastError();
str = "NET_DVR_CaptureJPEGPicture failed, error code= " + iLastErr;
DebugInfo(str);
return;
}
else
{
str = "NET_DVR_CaptureJPEGPicture succ and the saved file is " + sJpegPicFileName;
DebugInfo(str);
}
//JEPG抓图,数据保存在缓冲区中 Capture a JPEG picture and save in the buffer
uint iBuffSize = 400000; //缓冲区大小需要不小于一张图片数据的大小 The buffer size should not be less than the picture size
byte[] byJpegPicBuffer = new byte[iBuffSize];
uint dwSizeReturned = 0;
if (!CHCNetSDK.NET_DVR_CaptureJPEGPicture_NEW(m_lUserID, lChannel, ref lpJpegPara, byJpegPicBuffer, iBuffSize, ref dwSizeReturned))
{
iLastErr = CHCNetSDK.NET_DVR_GetLastError();
str = "NET_DVR_CaptureJPEGPicture_NEW failed, error code= " + iLastErr;
DebugInfo(str);
return;
}
else
{
//将缓冲区里的JPEG图片数据写入文件 save the data into a file
string str = "buffertest.jpg";
FileStream fs = new FileStream(str, FileMode.Create);
int iLen = (int)dwSizeReturned;
fs.Write(byJpegPicBuffer, 0, iLen);
fs.Close();
str = "NET_DVR_CaptureJPEGPicture_NEW succ and save the data in buffer to 'buffertest.jpg'.";
DebugInfo(str);
}
return;
}
以下是转换的
Dim lChannel As Integer = iChannelNum(CInt(iSelIndex))
Dim lpJpegPara As CHCNetSDK.NET_DVR_JPEGPARA = New CHCNetSDK.NET_DVR_JPEGPARA()
lpJpegPara.wPicQuality = 0
lpJpegPara.wPicSize = &HfF
Dim sJpegPicFileName As String
sJpegPicFileName = "filetest.jpg"
If Not CHCNetSDK.NET_DVR_CaptureJPEGPicture(m_lUserID, lChannel, lpJpegPara, sJpegPicFileName) Then
iLastErr = CHCNetSDK.NET_DVR_GetLastError()
str = "NET_DVR_CaptureJPEGPicture failed, error code= " & iLastErr
DebugInfo(str)
Return
Else
str = "NET_DVR_CaptureJPEGPicture succ and the saved file is " & sJpegPicFileName
DebugInfo(str)
End If
Dim iBuffSize As UInteger = 400000
Dim byJpegPicBuffer As Byte() = New Byte(iBuffSize - 1) {}
Dim dwSizeReturned As UInteger = 0
If Not CHCNetSDK.NET_DVR_CaptureJPEGPicture_NEW(m_lUserID, lChannel, lpJpegPara, byJpegPicBuffer, iBuffSize, dwSizeReturned) Then
iLastErr = CHCNetSDK.NET_DVR_GetLastError()
str = "NET_DVR_CaptureJPEGPicture_NEW failed, error code= " & iLastErr
DebugInfo(str)
Return
Else
Dim str As String = "buffertest.jpg"
Dim fs As FileStream = New FileStream(str, FileMode.Create)
Dim iLen As Integer = CInt(dwSizeReturned)
fs.Write(byJpegPicBuffer, 0, iLen)
fs.Close()
str = "NET_DVR_CaptureJPEGPicture_NEW succ and save the data in buffer to 'buffertest.jpg'."
DebugInfo(str)
End If
各种报错,引用方面没事,我能处理。应该怎么修改才能正常使用啊