/// <summary> start all the interfaces, graphs and preview window. </summary> bool StartupVideo(UCOMIMoniker mon) { int hr; try { if (!CreateCaptureDevice(mon)) { return(false); } if (!GetInterfaces()) { return(false); } if (!SetupGraph()) { return(false); } if (!SetupVideoWindow()) { return(false); } #if DEBUG DsROT.AddGraphToRot(graphBuilder, out rotCookie); // graphBuilder capGraph #endif hr = mediaCtrl.Run(); if (hr < 0) { Marshal.ThrowExceptionForHR(hr); } bool hasTuner = DsUtils.ShowTunerPinDialog(capGraph, capFilter, this.Handle); // toolBarBtnTune.Enabled = hasTuner; return(true); } catch (Exception ee) { MessageBox.Show(this, "Could not start video stream\r\n" + ee.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } }
/// <summary> start all the interfaces, graphs and preview window. </summary> bool StartupVideo(UCOMIMoniker mon) { int hr; try { if (!CreateCaptureDevice(mon)) { return(false); } if (!GetInterfaces()) { return(false); } if (!SetupGraph()) { return(false); } if (!SetupVideoWindow()) { return(false); } #if DEBUG //DsROT.AddGraphToRot( graphBuilder, out rotCookie ); // graphBuilder capGraph rot = new DsROTEntry(graphBuilder); #endif hr = mediaCtrl.Run(); if (hr < 0) { Marshal.ThrowExceptionForHR(hr); } bool hasTuner = DsUtils.ShowTunerPinDialog(capGraph, capFilter, this.Handle); //tuneBtn.Enabled = hasTuner; return(true); } catch { return(false); } }
/// <summary> handler for toolbar button clicks. </summary> private void toolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) { try { Trace.WriteLine("!!BTN: toolBar_ButtonClick"); int hr; if (sampGrabber == null) { return; } Trace.WriteLine("!!BTN: toolBarBtnGrab"); if (savedArray == null) { int size = videoInfoHeader.BmiHeader.ImageSize; if ((size < 1000) || (size > 16000000)) { return; } savedArray = new byte[size + 64000]; } toolBarBtnSave.Enabled = false; Image old = pictureBox.Image; //pictureBox.Image = null; if (old != null) { old.Dispose(); } toolBarBtnGrab.Enabled = false; captured = false; hr = sampGrabber.SetCallback(this, 1); Trace.WriteLine("!!BTN: toolBarBtnSave"); if (capGraph != null) { DsUtils.ShowTunerPinDialog(capGraph, capFilter, this.Handle); } } catch (Exception) {} }
/// <summary> handler for toolbar button clicks. </summary> private void toolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) { Trace.WriteLine("!!BTN: toolBar_ButtonClick"); int hr; if (sampGrabber == null) { return; } if (e.Button == toolBarBtnGrab) { Trace.WriteLine("!!BTN: toolBarBtnGrab"); if (savedArray == null) { int size = videoInfoHeader.BmiHeader.ImageSize; if ((size < 1000) || (size > 16000000)) { return; } savedArray = new byte[size + 64000]; } toolBarBtnSave.Enabled = false; Image old = pictureBox.Image; pictureBox.Image = null; if (old != null) { old.Dispose(); } toolBarBtnGrab.Enabled = false; captured = false; hr = sampGrabber.SetCallback(this, 1); } else if (e.Button == toolBarBtnSave) { Trace.WriteLine("!!BTN: toolBarBtnSave"); SaveFileDialog sd = new SaveFileDialog(); sd.FileName = @"DsNET.bmp"; sd.Title = "Save Image as..."; sd.Filter = "Bitmap file (*.bmp)|*.bmp"; sd.FilterIndex = 1; if (sd.ShowDialog() != DialogResult.OK) { return; } pictureBox.Image.Save(sd.FileName, ImageFormat.Bmp); // save to new bmp file } else if (e.Button == toolBarBtnTune) { if (capGraph != null) { DsUtils.ShowTunerPinDialog(capGraph, capFilter, this.Handle); } } }