NewTOAPIA.Media.Capture.VideoCaptureDevice.GetCaptureSize C# (CSharp) Method

GetCaptureSize() private method

private GetCaptureSize ( ) : void
return void
        void GetCaptureSize()
        {
            int hr = 0;

            // After the filter is added to the graph, and before
            // it is connected to anything, we need to set the format
            // and size that we expect.
            AMMediaType mt = new AMMediaType();

            hr = sampleGrabber.GetConnectedMediaType(mt);
            DsError.ThrowExceptionForHR(hr);

            try
            {
                if ((mt.formatType != FormatType.VideoInfo) || (mt.formatPtr == IntPtr.Zero))
                {
                    throw new NotSupportedException("Unknown Grabber Media Format");
                }

                // Get the struct
                VIDEOINFOHEADER videoInfoHeader = new VIDEOINFOHEADER();
                Marshal.PtrToStructure(mt.formatPtr, videoInfoHeader);

                // Grab the size info
                fGrabber.Width = videoInfoHeader.BmiHeader.biWidth;
                fGrabber.Height = videoInfoHeader.BmiHeader.biHeight;
                fGrabber.FrameBytes = (int)videoInfoHeader.BmiHeader.biSizeImage;
            }
            finally
            {
                mt.Dispose();
            }

        }