コード例 #1
0
 private void FrameReceived(IntPtr lwnd, IntPtr lpVHdr)
 {
     NativeMethods.VIDEOHDR videoHeader = (NativeMethods.VIDEOHDR)Marshal.PtrToStructure(lpVHdr, typeof(NativeMethods.VIDEOHDR));
     if ((videoHeader.dwBytesUsed > 0) && (m_captureTemp.Length == 0))
     {
         string tempFile = System.IO.Path.GetTempFileName();
         if (NativeMethods.SendMessage(m_captureHwnd, NativeMethods.WM_CAP_FILE_SAVEDIB, 0, tempFile) == 1)
         {
             m_captureTemp = tempFile;
             NativeMethods.SendMessageCallback(m_captureHwnd, NativeMethods.WM_CAP_SET_CALLBACK_FRAME, 0, null);
         }
     }
 }
コード例 #2
0
        void FrameCallback(IntPtr hWnd, ref NativeMethods.VIDEOHDR vhdr)
        {
            if (hWnd == IntPtr.Zero)
            {
                return;
            }

            long timestamp = CurrentMillis.Millis;

            NativeMethods.SendMessage(mCapHwnd, WM_CAP_COPY, 0, 0);

            if (FrameReady != null)
            {
                //IntPtr data = vhdr.lpData;
                //NativeMethods.BITMAPINFO binfo = NativeMethods.BITMAPINFO.Default;
                //Bitmap bmp = new Bitmap(binfo.biWidth, binfo.biHeight, binfo.biWidth * binfo.biBitCount / 8, System.Drawing.Imaging.PixelFormat.Format24bppRgb, data);
                VideoFrame f = new VideoFrame(++currentFrame, new Bitmap(GetClipboardImage()), timestamp);
                FrameReady(this, new FrameReadyEventArgs(f));
            }
        }