Exemple #1
0
		public void GetFrameOpen()
		{
			var bih = new AviInterop.BitmapInfoHeader
			{
				biBitCount = CountBitsPerPixel,
				biPlanes = 1
			};
			bih.biSize = Marshal.SizeOf(bih);
			getFrameObject = AviInterop.AVIStreamGetFrameOpen(StreamPointer, ref bih);
			if (getFrameObject == 0)
				throw new CodecNotFoundException();

			isFrameOpen = true;
		}
Exemple #2
0
		public VideoStream(int filePtr, IntPtr streamPtr)
			: base(filePtr, streamPtr)
		{
			var bih = new AviInterop.BitmapInfoHeader();
			int size = Marshal.SizeOf(bih);
			AviInterop.AVIStreamReadFormat(StreamPointer, 0, ref bih, ref size);
			AviInterop.StreamInfo streamInfo = GetStreamInfo();

			FrameRate = streamInfo.dwRate / (float)streamInfo.dwScale;
			Width = streamInfo.rcFrame.right;
			Height = streamInfo.rcFrame.bottom;
			FrameSize = bih.biSizeImage;
			CountBitsPerPixel = CalculateBitsPerPixel(bih.biBitCount);
			FirstFrame = AviInterop.AVIStreamStart(StreamPointer);
			CountFrames = AviInterop.AVIStreamLength(StreamPointer);
		}
Exemple #3
0
        public void GetFrameOpen()
        {
            var bih = new AviInterop.BitmapInfoHeader
            {
                biBitCount = CountBitsPerPixel,
                biPlanes   = 1
            };

            bih.biSize     = Marshal.SizeOf(bih);
            getFrameObject = AviInterop.AVIStreamGetFrameOpen(StreamPointer, ref bih);
            if (getFrameObject == 0)
            {
                throw new CodecNotFoundException();
            }

            isFrameOpen = true;
        }
Exemple #4
0
        public VideoStream(int filePtr, IntPtr streamPtr)
            : base(filePtr, streamPtr)
        {
            var bih  = new AviInterop.BitmapInfoHeader();
            int size = Marshal.SizeOf(bih);

            AviInterop.AVIStreamReadFormat(StreamPointer, 0, ref bih, ref size);
            AviInterop.StreamInfo streamInfo = GetStreamInfo();

            FrameRate         = streamInfo.dwRate / (float)streamInfo.dwScale;
            Width             = streamInfo.rcFrame.right;
            Height            = streamInfo.rcFrame.bottom;
            FrameSize         = bih.biSizeImage;
            CountBitsPerPixel = CalculateBitsPerPixel(bih.biBitCount);
            FirstFrame        = AviInterop.AVIStreamStart(StreamPointer);
            CountFrames       = AviInterop.AVIStreamLength(StreamPointer);
        }
Exemple #5
0
		public byte[] GetStreamData(int position, out AviInterop.BitmapInfoHeader header)
		{
			if (!isFrameOpen)
				throw new Exception("GetFrameOpen needs to be called before GetStreamData!");

			int dib = AviInterop.AVIStreamGetFrame(getFrameObject, FirstFrame + position);
			header = new AviInterop.BitmapInfoHeader();
			header = (AviInterop.BitmapInfoHeader)Marshal.PtrToStructure((IntPtr)dib, header.GetType());
			if (header.biSizeImage < 1)
				throw new Exception("Exception in VideoStreamGetFrame");

			int bihSize = Marshal.SizeOf(header);
			var bitmapData =
				new byte[header.biSizeImage + (header.biBitCount < 16 ? PaletteSize : 0)];
			Marshal.Copy((IntPtr)(dib + bihSize), bitmapData, 0, bitmapData.Length);

			return bitmapData;
		}
Exemple #6
0
        public byte[] GetStreamData(int position, out AviInterop.BitmapInfoHeader header)
        {
            if (!isFrameOpen)
            {
                throw new Exception("GetFrameOpen needs to be called before GetStreamData!");
            }

            int dib = AviInterop.AVIStreamGetFrame(getFrameObject, FirstFrame + position);

            header = new AviInterop.BitmapInfoHeader();
            header = (AviInterop.BitmapInfoHeader)Marshal.PtrToStructure((IntPtr)dib, header.GetType());
            if (header.biSizeImage < 1)
            {
                throw new Exception("Exception in VideoStreamGetFrame");
            }

            int bihSize    = Marshal.SizeOf(header);
            var bitmapData =
                new byte[header.biSizeImage + (header.biBitCount < 16 ? PaletteSize : 0)];

            Marshal.Copy((IntPtr)(dib + bihSize), bitmapData, 0, bitmapData.Length);

            return(bitmapData);
        }