Exemple #1
0
        /// <summary>
        /// 抓图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btndraw_Click(object sender, EventArgs e)
        {
            try
            {
                if (currentDefInfo.Vendor == 0)
                {
                    //图片保存路径和文件名
                    string picFileName = "C:\\maspicture\\" + currentDefInfo.Devname + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bmp";

                    //BMP抓图 Capture a BMP picture
                    if (!HK32ChCNetSDK.NET_DVR_CapturePicture(m_lRealHandle, picFileName))
                    {
                        var iLastErr = HK32ChCNetSDK.NET_DVR_GetLastError();
                        staticMsg = string.Format("视频测点 {0} 抓图失败:NET_DVR_CapturePicture_{1}", currentDefInfo.Devname, iLastErr);
                        this.StaticMsg.Caption = staticMsg;
                    }
                    else
                    {
                        staticMsg = string.Format("视频测点 {0} 抓图成功:{1}", currentDefInfo.Devname, picFileName);
                        this.StaticMsg.Caption = staticMsg;
                    }
                }
                else if (currentDefInfo.Vendor == 1)
                {
                    if (m_IsSetCaptureCallBack == false)
                    {
                        NETClient.SetSnapRevCallBack(m_SnapRevCallBack, IntPtr.Zero);
                        m_IsSetCaptureCallBack = true;
                    }
                    NET_SNAP_PARAMS snap = new NET_SNAP_PARAMS();
                    snap.Channel   = (uint)0;
                    snap.Quality   = 6;
                    snap.ImageSize = 2;
                    snap.mode      = 0;
                    snap.InterSnap = 0;
                    snap.CmdSerial = m_SnapSerialNum;

                    bool ret = NETClient.SnapPictureEx(loginID, snap, IntPtr.Zero); //call capture function.
                    if (ret)
                    {
                        m_SnapSerialNum++;
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("视频测点抓图失败!" + ex.Message);
            }
        }
Exemple #2
0
        /// <summary>
        /// 异步抓图请求
        /// </summary>
        /// <param name="_LoginID">登录序列号</param>
        /// <param name="ChannelID">通道号</param>
        /// <returns></returns>
        public string GetChannelPictureEx(IntPtr _LoginID, int ChannelID)
        {
            NET_SNAP_PARAMS asyncSnap = new NET_SNAP_PARAMS();

            asyncSnap.Channel   = (uint)ChannelID;
            asyncSnap.Quality   = 6;
            asyncSnap.ImageSize = 2;
            asyncSnap.mode      = 0;
            asyncSnap.InterSnap = 0;
            bool ret = NETClient.SnapPictureEx(_LoginID, asyncSnap, IntPtr.Zero);

            Thread.Sleep(1000);
            if (ret)
            {
                return(filePathPicture);
            }
            else
            {
                return(null);
            }
        }
 public static extern bool CLIENT_SnapPictureEx(IntPtr lLoginID, ref NET_SNAP_PARAMS par, IntPtr reserved);