Beispiel #1
0
        void videoSource_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            currentFrame = (Bitmap)eventArgs.Frame.Clone();
            browserFrame = (Bitmap)eventArgs.Frame.Clone();

            if ((captureThread == null || !captureThread.IsAlive) && recordVideo)
            {
                Bitmap threadFrame = (Bitmap)currentFrame.Clone();
                captureThread = new Thread(
                    new ThreadStart(
                        delegate
                {
                    writer.AddFrame(threadFrame);
                }));
                captureThread.Start();
            }


            if ((browserThread == null || !browserThread.IsAlive) && browserRunning)
            {
                browserThread  = new Thread(new ThreadStart(BrowserSnapshot));
                browserRunning = true;
                browserThread.Start();
            }

            CaptureBox.Invoke(
                new Action(
                    delegate
            {
                CaptureBox.Image = currentFrame;
            }));
        }
Beispiel #2
0
 private void CaptureButton_Click(object sender, EventArgs e)
 {
     if (videoSource != null)
     {
         if (videoSource.IsRunning)
         {
             videoSource.SignalToStop();
             videoSource.WaitForStop();
             CaptureBox.Invoke(
                 new Action(
                     delegate
             {
                 CaptureBox.Image = null;
                 CaptureBox.Invalidate();
             }));
             CaptureButton.Name = "Start";
         }
         else
         {
             videoSource.NewFrame += videoSource_NewFrame;
             videoSource.Start();
             CaptureButton.Name = "Stop";
         }
         SnapshotButton.Enabled = videoSource.IsRunning;
         RecordButton.Enabled   = videoSource.IsRunning;
     }
 }
Beispiel #3
0
        private void ResolutionCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            videoSource.VideoResolution = videoSource.VideoCapabilities[ResolutionCB.SelectedIndex];
            if (videoSource.IsRunning)
            {
                videoSource.SignalToStop();
                videoSource.WaitForStop();

                SnapshotButton.Enabled = videoSource.IsRunning;
                RecordButton.Enabled   = videoSource.IsRunning;

                CaptureBox.Invoke(
                    new Action(
                        delegate
                {
                    CaptureBox.Image = null;
                    CaptureBox.Invalidate();
                }));
                videoSource.NewFrame += videoSource_NewFrame;
                videoSource.Start();

                SnapshotButton.Enabled = videoSource.IsRunning;
                RecordButton.Enabled   = videoSource.IsRunning;
            }

            CaptureButton.Enabled = true;
        }
Beispiel #4
0
 public void ApplyDataImpl(byte[] data)
 {
     if (CaptureBox.InvokeRequired)
     {
         var d = new ApplyDelegate(ApplyDataImpl);
         CaptureBox.Invoke(d, data);
     }
     else
     {
         ApplyModeDelegate(CaptureBox, data);
         Refresh();
     }
 }
Beispiel #5
0
 public void ApplyRGBAInternal(byte[] data)
 {
     if (CaptureBox.InvokeRequired)
     {
         var d = new ApplyDelegate(ApplyRGBAInternal);
         CaptureBox.Invoke(d, data);
     }
     else
     {
         ApplyRGBAToPictureBox(CaptureBox, data);
         Refresh();
     }
 }
Beispiel #6
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            recordVideo    = false;
            browserRunning = false;
            if (videoSource.IsRunning)
            {
                videoSource.SignalToStop();

                CaptureBox.Invoke(
                    new Action(
                        delegate
                {
                    CaptureBox.Image = null;
                    CaptureBox.Invalidate();
                }));

                videoSource = null;
            }
        }