private void CreateStream() { AviReadingMethods.AVISTREAMINFO strhdr = new AviReadingMethods.AVISTREAMINFO(); strhdr.fccType = fccType; strhdr.fccHandler = fccHandler; strhdr.dwScale = 1; strhdr.dwRate = frameRate; strhdr.dwSuggestedBufferSize = (UInt32)(height * stride); strhdr.dwQuality = 10000; strhdr.rcFrame.bottom = (UInt32)height; strhdr.rcFrame.right = (UInt32)width; strhdr.szName = new UInt16[64]; int result = AviReadingMethods.AVIFileCreateStream(aviFile, out aviStream, ref strhdr); if (result != 0) { throw new Exception("Problem podczas tworzenia streamu pliku AVI" + result.ToString()); } AviReadingMethods.BITMAPINFOHEADER bi = new AviReadingMethods.BITMAPINFOHEADER(); bi.biSize = (UInt32)Marshal.SizeOf(bi); bi.biWidth = (Int32)width; bi.biHeight = (Int32)height; bi.biPlanes = 1; bi.biBitCount = 24; bi.biSizeImage = (UInt32)(stride * height); result = AviReadingMethods.AVIStreamSetFormat(aviStream, 0, ref bi, Marshal.SizeOf(bi)); if (result != 0) { throw new Exception("Problem podczas tworzenia streamu pliku AVI" + result.ToString()); } }
public void Open(string fileName) { AviReadingMethods.AVIFileInit(); int result = AviReadingMethods.AVIFileOpen( ref aviFile, fileName, AviReadingMethods.OF_SHARE_DENY_WRITE, 0); if (result != 0) { throw new Exception("Problem podczas otwierania pliku AVI" + Environment.NewLine + "Upewnij się, że plik nie został poddany kompresji"); } result = AviReadingMethods.AVIFileGetStream( aviFile, out aviStream, AviReadingMethods.StreamtypeVIDEO, 0); if (result != 0) { throw new Exception("Problem podczas otwierania pliku AVI" + Environment.NewLine + "Upewnij się, że plik nie został poddany kompresji"); } firstFrame = AviReadingMethods.AVIStreamStart(aviStream.ToInt32()); countFrames = AviReadingMethods.AVIStreamLength(aviStream.ToInt32()); streamInfo = new AviReadingMethods.AVISTREAMINFO(); result = AviReadingMethods.AVIStreamInfo(aviStream.ToInt32(), ref streamInfo, Marshal.SizeOf(streamInfo)); if (result != 0) { throw new Exception("Problem podczas otwierania pliku AVI" + Environment.NewLine + "Upewnij się, że plik nie został poddany kompresji"); } bih = new AviReadingMethods.BITMAPINFOHEADER(); bih.biBitCount = 24; bih.biClrImportant = 0; bih.biClrUsed = 0; bih.biCompression = 0; bih.biHeight = (Int32)streamInfo.rcFrame.bottom; bih.biWidth = (Int32)streamInfo.rcFrame.right; bih.biPlanes = 1; bih.biSize = (UInt32)Marshal.SizeOf(bih); bih.biXPelsPerMeter = 0; bih.biYPelsPerMeter = 0; getFrameObject = AviReadingMethods.AVIStreamGetFrameOpen(aviStream, ref bih); if (getFrameObject == 0) { throw new Exception("Problem podczas otwierania pliku AVI" + Environment.NewLine + "Upewnij się, że plik nie został poddany kompresji"); } }