/// <summary> /// 抓图处理代码 /// </summary> /// <param name="hPlayHandle">播放句柄</param> /// <param name="bmpPath">图像促存路径</param> private bool CapturePicture(int hPlayHandle, string bmpPath) { if (DHClient.DHCapturePicture(hPlayHandle, bmpPath)) { //抓图成功处理 return(true); } else { //抓图失败处理 return(false); } }
/// <summary> /// 抓图处理代码 /// </summary> /// <param name="hPlayHandle">播放句柄</param> /// <param name="bmpPath">图像促存路径</param> private void CapturePicture(int hPlayHandle, string bmpPath) { if (DHClient.DHCapturePicture(hPlayHandle, bmpPath)) { //抓图成功处理 MessageBox.Show("抓图成功! 图片路径:" + bmpPath, pMsgTitle); } else { //抓图失败处理 MessageBox.Show("抓图失败!", pMsgTitle); } }
/// <summary> /// 抓图处理 /// </summary> /// <param name="iRealPlay"></param> /// <param name="bmpPath"></param> private void CapturePicture(int iRealPlay, string bmpPath) { if (DHClient.DHCapturePicture(iRealPlay, bmpPath)) { if (IsSuccess) { IsSuccess = true; } else { IsSuccess = false; } } else { IsSuccess = false; } }
private void btnTomarFoto_Click(object sender, EventArgs e) { string bmpPath = Application.StartupPath + @"\DH_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bmp"; if (pRealPlayHandle[this.channel] == 0) { MessageBox.Show("Manejador no encontrado!", pMsgTitle); return; } if (DHClient.DHCapturePicture(pRealPlayHandle[this.channel], bmpPath)) { //MessageBox.Show("Foto tomada con exito: " + bmpPath, pMsgTitle); byte[] rawData = File.ReadAllBytes(bmpPath); if (this.salvarFotoEnDB(rawData)) { MessageBox.Show("Foto tomada con éxito!", "Info"); } File.Delete(bmpPath); } else { MessageBox.Show("Error al tomar foto en DHCapturePicture", pMsgTitle); } }
/// <summary> /// 抓拍图片 /// </summary> /// <param name="path"></param> /// <param name="timeout">超时时间(ms)</param> /// <returns></returns> public override bool SnapShotTo(ref string path, int timeout, bool force) { bool success = false; try { if (_IsReadyForSnapshot) { //不打开视频时抓拍 IVideoCapture capture = VideoCaptureManager.Instance[(int)VideoServerType.DaHua]; if (capture != null) { path = capture.CapturePicture(this.VideoSource, force); success = !string.IsNullOrEmpty(path); } } else { lock (_StatusLock) { //////发起订阅设备事件消息 ////if (m_nRealLoadPic == 0) ////{ //// m_nRealLoadPic = DHClient.DHRealLoadPicture(m_nLoginID, VideoSource.Channel, EventIvs.EVENT_IVS_ALL, anaCallback, 0); ////} //////设置上传图片的存储路径 ////snapPath = path; //////触发手动抓拍测试 ////MANUAL_SNAP_PARAMETER snap = new MANUAL_SNAP_PARAMETER(); ////snap.nChannel = VideoSource.Channel; ////IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(snap)); ////Marshal.StructureToPtr(snap, ptr, false); ////bool bRet = DHClient.DHControlDevice(m_nLoginID, CtrlType.DH_MANUAL_SNAP, ptr, 1000); ////System.Runtime.InteropServices.Marshal.FreeHGlobal(ptr); //////等待图片上传 ////_SnapEvent.WaitOne(timeout); //////清除上传图片的存储路径 ////snapPath = string.Empty; ////////取消订阅事件消息 //////if (m_nRealLoadPic != 0) //////{ ////// DHClient.DHStopLoadPic(m_nRealLoadPic); ////// m_nRealLoadPic = 0; //////} //if (m_realPlayH != 0) //{ // success = DHClient.DHCapturePicture(m_realPlayH, path); //} //打开视频时抓拍 if (m_realPlayH != 0) { success = DHClient.DHCapturePicture(m_realPlayH, path); } } } } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); } return(success); }