Exemplo n.º 1
0
        void FrameReceived(IntPtr hwnd, ref VIDEOHDR hdr)
        {
            switch (fBitmapInfo.bmiHeader.biCompression)
            {
                case GDI32.BI_BITFIELDS:
                    Console.WriteLine("Bitfields");
                    break;
                case GDI32.BI_JPEG:
                    Console.WriteLine("JPEG");
                    break;
                case GDI32.BI_PNG:
                    Console.WriteLine("PNG");
                    break;

                case GDI32.BI_RGB:
                    {
                        //Console.WriteLine("RGB");
                        //PixelAccessorBGRb accessor = new PixelAccessorBGRb(fCamera.Width, fCamera.Height, PixmapOrientation.BottomToTop, hdr.lpData);
                        //SourceCopy srcCopy = new SourceCopy();

                        //fPixelBuffer.ApplyBinaryColorOperator(srcCopy, accessor);
                        //Rectangle srcRect = new Rectangle(0, 0, fCamera.Width, fCamera.Height);
                        //bool success = DeviceContextClientArea.AlphaBlend(fPixelBuffer.DeviceContext, srcRect, srcRect, 255);
                    }
                    break;

                case GDI32.BI_RLE4:
                    Console.WriteLine("RLE4");
                    break;
                case GDI32.BI_RLE8:
                    Console.WriteLine("RLE8");
                    break;

                default:
                    {
                        // Construct a stream on the bits
                        byte[] data = new byte[hdr.dwBytesUsed];
                        Marshal.Copy(hdr.lpData, data, 0, (int)hdr.dwBytesUsed);
                        MemoryStream ms = new MemoryStream(data);
                        Bitmap bm = (Bitmap)Bitmap.FromStream(ms);

                        string dStr = FOURCC.FourCCToString(FOURCC.MakeFourCC(data));
                        Console.WriteLine("data: {0}", dStr);

                        ICINFO icinfo = new ICINFO();
                        icinfo.dwSize = (uint)Marshal.SizeOf(icinfo);

                        uint fccHandler = 0;
                        while (Vfw.ICInfo(0, fccHandler, ref icinfo))
                        {
                            Console.WriteLine("Info: {0}  Driver: {1}", icinfo.szName, icinfo.szDriver);
                            string fccTypeStr = FOURCC.FourCCToString(icinfo.fccType);
                            string fccHandlerStr = FOURCC.FourCCToString(icinfo.fccHandler); 
                            Console.WriteLine("Form1.FrameReceived - FCC: {0}  Handler: {1}", fccTypeStr, fccHandlerStr);
                            fccHandler++;
                        }

                        //BITMAPINFO bmiOut = fPixelBuffer.BitmapInfo;
                        UInt32 vcap = FOURCC.MakeFourCC('v', 'c', 'a','p');
                        UInt32 VIDC = FOURCC.MakeFourCC('V', 'I', 'D', 'C');

                        #region temporarily off
                        /*
                        BITMAPINFOHEADER bmihIn = fPixelBuffer.BitmapInfo.bmiHeader;
                        BITMAPINFOHEADER bmihOut = new BITMAPINFOHEADER();
                        bmihOut.Init();
                        IntPtr handle = Vfw.ICLocate(VIDC, 0, ref bmihIn, ref bmihOut, 0);
                        Console.WriteLine("Handle: {0}", handle);
    */                    
    #endregion

                        //// Try to load it using the Image class
                        //Bitmap bm = (Bitmap)Image.FromStream(ms);
                        //Rectangle srcRect = new Rectangle(0, 0, fCamera.Width, fCamera.Height);
                        //bool success = DeviceContextClientArea.AlphaBlend(fPixelBuffer.DeviceContext, srcRect, srcRect, 255);

                    }
                    break;
            }

            
            //BITMAPINFO bmiOut = fPixelBuffer.BitmapInfo;
            //BITMAPINFOHEADER bmihIn = fPixelBuffer.BitmapInfo.bmiHeader;
            //BITMAPINFOHEADER bmihOut = new BITMAPINFOHEADER();
            //bmihOut.Init();

            //StringBuilder sb = new StringBuilder(100);
            //COMPVARS cvars = new COMPVARS();
            //cvars.cbSize = Marshal.SizeOf(cvars);

            //success = Vfw.ICCompressorChoose(this.Handle, 0, IntPtr.Zero, IntPtr.Zero, ref cvars, null);
            //IntPtr handle = Vfw.ICLocate(fBitmapInfo.bmiHeader.biCompression, 0, ref bmihIn, ref bmihOut, 0);
            //IntPtr bmHandle = fDecompressor.DeCompress(ref fBitmapInfo, hdr.lpData, ref bmiOut);

            //Console.WriteLine("Form1.FrameReceived - Compression: {0}", FOURCC.FourCCToString(fBitmapInfo.bmiHeader.biCompression));
            //Console.WriteLine("{0}", handle);
            
        }
Exemplo n.º 2
0
 public static extern bool ICInfo(uint fccType, uint fccHandler, ref ICINFO lpicinfo);