各位GGJJ,在网上找到了一些个根据avicap32.dll来进行摄像头编程的c#的代码,但是在设置显示的图像的长宽的时候,那个capSetVideoFormat不起作用,另外,就是保存图像的时候,应该是bmp的格式,300w像素摄像头,保存下来有900k的样子,我用windows自带的视频工具(点击我的电脑后,显示的我的视频和扫仪处)保存的大小却只有28k,请问这是如何处理的呢。
   又在网上找到个说明(http://www.comprg.com.cn/detail.asp?hw_id=2655),说要先调用capGetVideoFormatSize,但是avicap32.dll里面却没有这个函数,请问各位大哥大姐,这个该如何处理呢。
   下面是我的代码,请大家帮帮忙,非常感谢
     public class WebCamera
    {
        //  Constructur
        public WebCamera(IntPtr handle, int width, int height)
        {
            mControlPtr = handle;
            mWidth = width;
            mHeight = height;
        }
        public void StartWebCam()
        {
            byte[] lpszName = new byte[100];
            byte[] lpszVer = new byte[100];
            ShowVideo.capGetDriverDescriptionA(0, lpszName, 100, lpszVer, 100);
            this.lwndC = ShowVideo.capCreateCaptureWindowA(lpszName, ShowVideo.WS_VISIBLE + ShowVideo.WS_CHILD, 0, 0, mWidth, mHeight, mControlPtr, 0);
            if (this.capDriverConnect(this.lwndC, 0))
            {
                this.capPreviewRate(this.lwndC, 66);
                this.capPreview(this.lwndC, true);
                ShowVideo.BITMAPINFO bitmapinfo = new ShowVideo.BITMAPINFO();
                bitmapinfo.bmiHeader.biSize = ShowVideo.SizeOf(bitmapinfo.bmiHeader);
                //bitmapinfo.bmiHeader.biWidth = 352;
                //bitmapinfo.bmiHeader.biHeight = 288;
                //bitmapinfo.bmiHeader.biPlanes = 1;
               //int dwsize= ShowVideo.capGetVideoFormatSize(this.lwndC);
                bitmapinfo.bmiHeader.biWidth = 352;
                bitmapinfo.bmiHeader.biHeight = 288;
                bitmapinfo.bmiHeader.biPlanes = 1;
                //每个像素所有的比特数
                bitmapinfo.bmiHeader.biBitCount = 12;
                //bitmapinfo.bmiHeader.biBitCount = 24;
                this.capSetVideoFormat(this.lwndC, ref  bitmapinfo, ShowVideo.SizeOf(bitmapinfo));
                this.mFrameEventHandler = new ShowVideo.FrameEventHandler(frameCallBack);
                this.capSetCallbackOnFrame(this.lwndC, this.mFrameEventHandler);
                ShowVideo.SetWindowPos(this.lwndC, 0, 0, 0, mWidth, mHeight, 6);
            }
        }
        private bool capSetVideoFormat(IntPtr hcapwnd, ref  ShowVideo.BITMAPINFO bmpformat, int capformatsize)
        {
       
            return ShowVideo.SendMessage(hcapwnd, ShowVideo.WM_CAP_SET_VIDEOFORMAT, capformatsize, ref  bmpformat);
        }
}
       
       调用的时候,如下方法:
       WebCamera   wc = new WebCamera(panelPreview.Handle, panelPreview.Width, panelPreview.Height);
       wc.StartWebCam();       请问,我上述的代码是否哪里有问题???
       急待各位大大的指教啊。不甚感谢!!!