首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C# 开启摄像头拍照

2013-12-26 
求助C# 开启摄像头拍照网上找到的例子private void OpenPreviewWindow(){int iHeight 320int iWidth

求助C# 开启摄像头拍照
网上找到的例子

private void OpenPreviewWindow()
        {
            int iHeight = 320;
            int iWidth = 200;
            //
            //  Open Preview window in picturebox
            //
            hHwnd = capCreateCaptureWindowA(iDevice.ToString(), (WS_VISIBLE | WS_CHILD), 0, 0, 640, 480, pictureBox1.Handle.ToInt32(), 0);
            //
            //  Connect to device
            //
            if (SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) != 1)
            {
                //
                // Set the preview scale
                //
                SendMessage(hHwnd, WM_CAP_SET_SCALE, 1, 0);
                //
                // Set the preview rate in milliseconds
                //
                SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0);
                //
                // Start previewing the image from the camera
                //
                SendMessage(hHwnd, WM_CAP_SET_PREVIEW, 1, 0);
                //
                //  Resize window to fit in picturebox
                //
                SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, iWidth, iHeight, (SWP_NOMOVE | SWP_NOZORDER));
            }
            else
            {
                //
                //  Error connecting to device close window
                // 
                DestroyWindow(hHwnd);
            }
        }



求解释下capCreateCaptureWindowA   &    SendMessage两个方法的参数 ,另外求个可以使用的例子,这个代码有一定作用,但是并不能截取到图像.
[解决办法]
http://wangsf150.blog.163.com/blog/static/501495752011112361427157/

热点排行