Beispiel #1
0
 /// <summary>
 /// 打开视频设备
 /// </summary>
 public void StartWebCam()
 {
     byte[] lpszName = new byte[100];
     byte[] lpszVer  = new byte[100];
     UCVideoAPI.capGetDriverDescriptionA(0, lpszName, 100, lpszVer, 100);
     this.lwndC = UCVideoAPI.capCreateCaptureWindowA(lpszName, UCVideoAPI.WS_CHILD | UCVideoAPI.WS_VISIBLE, 0, 0, mWidth, mHeight, mControlPtr, 0);
     if (UCVideoAPI.SendMessage(lwndC, UCVideoAPI.WM_CAP_DRIVER_CONNECT, 0, 0))
     {
         UCVideoAPI.SendMessage(lwndC, UCVideoAPI.WM_CAP_SET_PREVIEWRATE, 100, 0);
         UCVideoAPI.SendMessage(lwndC, UCVideoAPI.WM_CAP_SET_PREVIEW, true, 0);
     }
 }
Beispiel #2
0
        /// <summary>
        ///拍照
        /// </summary>
        /// <param name=”path”>要保存bmp文件的路径</param>
        public void GrabImage(IntPtr hWndC, string path)
        {
            IntPtr hBmp = Marshal.StringToHGlobalAnsi(path);

            UCVideoAPI.SendMessage(lwndC, UCVideoAPI.WM_CAP_SAVEDIB, 0, hBmp.ToInt32());
        }
Beispiel #3
0
 /// <summary>
 /// 关闭视频设备
 /// </summary>
 public void CloseWebcam()
 {
     UCVideoAPI.SendMessage(lwndC, UCVideoAPI.WM_CAP_DRIVER_DISCONNECT, 0, 0);
 }