Пример #1
0
        public VfwAviWriter(string filename, int rate, int scale)
        {
            Initialize();
            int hr = VfwApi.AVIFileOpen(ref pfile_, filename, VfwApi.OF_CREATE | VfwApi.OF_SHARE_DENY_WRITE, IntPtr.Zero);

            if (hr != 0)
            {
                throw new VfwException("AVIFileOpen", hr);
            }
            rate_  = rate;
            scale_ = scale;
        }
Пример #2
0
        public void Open(string filename)
        {
            if (!File.Exists(filename))
            {
                throw new FileNotFoundException();
            }
            Initialize();
            int hr = VfwApi.AVIFileOpen(ref pfile_, filename, VfwApi.OF_READ | VfwApi.OF_SHARE_DENY_NONE, IntPtr.Zero);

            if (hr != 0)
            {
                throw new VfwException("AVIFileOpen", hr);
            }
            hr = VfwApi.AVIFileGetStream(pfile_, ref pavi_, 0, 0);
            if (hr != 0)
            {
                throw new VfwException("AVIFileGetStream", hr);
            }
            frame_start_  = VfwApi.AVIStreamStart(pavi_);
            frame_length_ = VfwApi.AVIStreamLength(pavi_);

            VfwApi.AVISTREAMINFO psi = new VfwApi.AVISTREAMINFO();
            hr = VfwApi.AVIStreamInfo(pavi_, ref psi, Marshal.SizeOf(new VfwApi.AVISTREAMINFO()));
            if (hr != 0)
            {
                throw new VfwException("AVIStreamInfo", hr);
            }
            rate_  = psi.dwRate;
            scale_ = psi.dwScale;

            pgf_ = VfwApi.AVIStreamGetFrameOpen(pavi_, IntPtr.Zero);
            if (pgf_ == IntPtr.Zero)
            {
                throw new VfwException("AVIStreamGetFrameOpen", 0);
            }
            GetBitmapHeader();
        }