Beispiel #1
0
        public VideoStrech(int aviFile, IntPtr aviStream)
        {
            this.aviFile = aviFile;
            this.aviStream = aviStream;

            Avi32.BITMAPINFOHEADER bih = new Avi32.BITMAPINFOHEADER();
            int size = Marshal.SizeOf(bih);
            Avi32.AVIStreamReadFormat(aviStream, 0, ref bih, ref size);
            Avi32.AVISTREAMINFO streamInfo = GetStreamInfo(aviStream);

            this.bitMaps = new List<Bitmap>();
            this.frameRate = (float)streamInfo.dwRate / (float)streamInfo.dwScale;
            this.width = (int)streamInfo.rcFrame.right;
            this.height = (int)streamInfo.rcFrame.bottom;
            this.frameSize = bih.biSizeImage;
            this.firstFrame = Avi32.AVIStreamStart(aviStream.ToInt32());
            this.position = streamInfo.dwStart;
            this.start = streamInfo.dwStart;
            this.length = streamInfo.dwLength;
            this.codec = Avi32.decode_mmioFOURCC(streamInfo.fccHandler);
        }
Beispiel #2
0
        private void SetFormat(IntPtr aviStream)
        {
            Avi32.BITMAPINFOHEADER bi = new Avi32.BITMAPINFOHEADER();
            bi.biSize = Marshal.SizeOf(bi);
            bi.biWidth = width;
            bi.biHeight = height;
            bi.biPlanes = 1;
            bi.biBitCount = countBitsPerPixel;
            bi.biSizeImage = frameSize;

            int result = Avi32.AVIStreamSetFormat(aviStream, 0, ref bi, bi.biSize);
            if (result != 0) { throw new Exception("Error in VideoStreamSetFormat: " + result.ToString()); }
        }
Beispiel #3
0
        public Bitmap GetSubsequentPosition(int framePosition)
        {
            IntPtr dib = Avi32.AVIStreamGetFrame(new IntPtr(getFrameObject), framePosition);
            Avi32.BITMAPINFOHEADER bih = new Avi32.BITMAPINFOHEADER();
            bih = (Avi32.BITMAPINFOHEADER)Marshal.PtrToStructure(dib, bih.GetType());

            Bitmap bmp = new Bitmap(this.width, this.height, PixelFormat.Format24bppRgb);
            BitmapData bmData = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

            int srcStride = bmData.Stride;
            int dstStride = bmData.Stride;

            int dst = bmData.Scan0.ToInt32() + dstStride * (height - 1);
            int src = dib.ToInt32() + Marshal.SizeOf(typeof(Avi32.BITMAPINFOHEADER));

            for (int y = 0; y < height; y++)
            {
                Avi32.memcpy(dst, src, srcStride);
                dst -= dstStride;
                src += srcStride;
            }

            bmp.UnlockBits(bmData);
            return bmp;
        }