Ejemplo n.º 1
0
        /// <summary>
        /// 开启摄像头
        /// </summary>
        public void StartWebCam()
        {
            byte[] lpszName = new byte[100];
            byte[] lpszVer  = new byte[100];

            AviCapture.capGetDriverDescriptionA(1, lpszName, 100, lpszVer, 100);
            this.lwndC = AviCapture.capCreateCaptureWindowA(lpszName, AviCapture.WS_VISIBLE + AviCapture.WS_CHILD, 0, 0, mWidth, mHeight, mControlPtr, 0);

            if (this.capDriverConnect(this.lwndC, 0))
            {
                this.capPreviewRate(this.lwndC, 66);

                this.capPreview(this.lwndC, true);
                this.capOverlay(this.lwndC, true);
                AviCapture.BITMAPINFO bitmapinfo = new AviCapture.BITMAPINFO();
                bitmapinfo.bmiHeader.biSize     = AviCapture.SizeOf(bitmapinfo.bmiHeader);
                bitmapinfo.bmiHeader.biWidth    = this.mWidth;
                bitmapinfo.bmiHeader.biHeight   = this.mHeight;
                bitmapinfo.bmiHeader.biPlanes   = 1;
                bitmapinfo.bmiHeader.biBitCount = 24;
                this.capSetVideoFormat(this.lwndC, ref bitmapinfo, AviCapture.SizeOf(bitmapinfo));

                this.mFrameEventHandler = new AviCapture.FrameEventHandler(FrameCallBack);
                this.capSetCallbackOnFrame(this.lwndC, this.mFrameEventHandler);
                AviCapture.SetWindowPos(this.lwndC, 0, 0, 0, mWidth, mHeight, 6);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 开启摄像头
        /// </summary>
        public void StartWebCam()
        {
            byte[] lpszName = new byte[100];
            byte[] lpszVer = new byte[100];

            AviCapture.capGetDriverDescriptionA(1, lpszName, 100, lpszVer, 100);
            this.lwndC = AviCapture.capCreateCaptureWindowA(lpszName, AviCapture.WS_VISIBLE + AviCapture.WS_CHILD, 0, 0, mWidth, mHeight, mControlPtr, 0);

            if (this.capDriverConnect(this.lwndC, 0))
            {
                this.capPreviewRate(this.lwndC, 66);

                this.capPreview(this.lwndC, true);
                this.capOverlay(this.lwndC, true);
                AviCapture.BITMAPINFO bitmapinfo = new AviCapture.BITMAPINFO();
                bitmapinfo.bmiHeader.biSize = AviCapture.SizeOf(bitmapinfo.bmiHeader);
                bitmapinfo.bmiHeader.biWidth = this.mWidth;
                bitmapinfo.bmiHeader.biHeight = this.mHeight;
                bitmapinfo.bmiHeader.biPlanes = 1;
                bitmapinfo.bmiHeader.biBitCount = 24;
                this.capSetVideoFormat(this.lwndC, ref bitmapinfo, AviCapture.SizeOf(bitmapinfo));

                this.mFrameEventHandler = new AviCapture.FrameEventHandler(FrameCallBack);
                this.capSetCallbackOnFrame(this.lwndC, this.mFrameEventHandler);
                AviCapture.SetWindowPos(this.lwndC, 0, 0, 0, mWidth, mHeight, 6);
            }
        }
Ejemplo n.º 3
0
 private bool capSetVideoFormat(IntPtr hCapWnd, ref AviCapture.BITMAPINFO BmpFormat, int CapFormatSize)
 {
     return(AviCapture.SendMessage(hCapWnd, AviCapture.WM_CAP_SET_VIDEOFORMAT, CapFormatSize, ref BmpFormat));
 }