/// <summary> /// Adds SampleGrabber for screenshot making. /// </summary> private void GraphBuilding_AddFilter_SampleGrabber(Action <Bitmap> bp, RotateFlipType rft) { int hr = 0; // Get the SampleGrabber interface DX.SampleGrabber = new SampleGrabber() as ISampleGrabber; // Configure the sample grabber DX.SampleGrabberFilter = DX.SampleGrabber as IBaseFilter; _pSampleGrabberHelper = new SampleGrabberHelper(DX.SampleGrabber, bp, rft); _pSampleGrabberHelper.ConfigureMode(); // Add the sample grabber to the graph hr = DX.FilterGraph.AddFilter(DX.SampleGrabberFilter, "Sample Grabber"); DsError.ThrowExceptionForHR(hr); }
/// <summary> /// Close and dispose all camera and DirectX stuff. /// </summary> public void CloseAll() { _bGraphIsBuilt = false; // close log file if needed try { CloseDirectShowLogFile(); } catch (Exception ex) { Debug.WriteLine(ex); } // stop rendering if (DX.MediaControl != null) { try { DX.MediaControl.StopWhenReady(); DX.MediaControl.Stop(); } catch (Exception ex) { Debug.WriteLine(ex); } } //FilterGraphTools.RemoveAllFilters(this.graphBuilder); #if DEBUG if (_rot != null) { _rot.Dispose(); } #endif // Dispose Managed Direct3D objects if (_pSampleGrabberHelper != null) { _pSampleGrabberHelper.Dispose(); _pSampleGrabberHelper = null; } DX.CloseInterfaces(); }