Exemple #1
0
        private VideoCompressor(uint fccHandler)
        {
            // Init bitmap info header
            Avi32Interop.BITMAPINFOHEADER bih = new Avi32Interop.BITMAPINFOHEADER();
            bih.Init();
            bih.biBitCount    = bitCount;
            bih.biCompression = 0;
            bih.biWidth       = bih.biHeight = biHeight;
            bih.biPlanes      = 1;
            // Open compressor
            IntPtr hic = Avi32Interop.ICOpen(Avi32Interop.ICTYPE_VIDEO, fccHandler, Avi32Interop.ICMODE_QUERY);

            if (hic == IntPtr.Zero)
            {
                int errorCode = Marshal.GetLastWin32Error();
                throw new AviException("ICOpen", errorCode);
            }
            try {
                // Check if compressor supports specified format
                int hr = Avi32Interop.ICCompressQuery(hic, ref bih, IntPtr.Zero);
                if (hr != Avi32Interop.ICERR_OK)
                {
                    throw new AviException("ICCompressQuery", hr);
                }
                // Get compressor info
                Avi32Interop.ICINFO ici = new Avi32Interop.ICINFO();
                ici.Init();
                hr = Avi32Interop.ICGetInfo(hic, out ici, ici.biSize);
                if (hr != 0)
                {
                    this.name = ici.szDescription;
                    // Check quality support
                    bool supportsQuality = (ici.dwFlags & Avi32Interop.VIDCF_QUALITY) == Avi32Interop.VIDCF_QUALITY;
                    if (supportsQuality)
                    {
                        if (Avi32Interop.ICERR_OK == Avi32Interop.ICGetDefaultQuality(hic, ref this.quality))
                        {
                            this.supportsQuality = true;
                        }
                    }
                    else
                    {
                        this.quality = defaultQuality;
                    }
                    this.fccHandler       = fccHandler;
                    this.fccHandlerString = FccHandlerToString(fccHandler);
                }
                else
                {
                    throw new AviException("ICGetInfo", hr);
                }
            }
            finally {
                Avi32Interop.ICClose(hic);
            }
        }
 private VideoCompressor(uint fccHandler)
 {
     // Init bitmap info header
      Avi32Interop.BITMAPINFOHEADER bih = new Avi32Interop.BITMAPINFOHEADER();
      bih.Init();
      bih.biBitCount = bitCount;
      bih.biCompression = 0;
      bih.biWidth = bih.biHeight = biHeight;
      bih.biPlanes = 1;
      // Open compressor
      IntPtr hic = Avi32Interop.ICOpen(Avi32Interop.ICTYPE_VIDEO, fccHandler, Avi32Interop.ICMODE_QUERY);
      if (hic == IntPtr.Zero) {
     int errorCode = Marshal.GetLastWin32Error();
     throw new AviException("ICOpen", errorCode);
      }
      try {
     // Check if compressor supports specified format
     int hr = Avi32Interop.ICCompressQuery(hic, ref bih, IntPtr.Zero);
     if (hr != Avi32Interop.ICERR_OK) {
        throw new AviException("ICCompressQuery", hr);
     }
     // Get compressor info
     Avi32Interop.ICINFO ici = new Avi32Interop.ICINFO();
     ici.Init();
     hr = Avi32Interop.ICGetInfo(hic, out ici, ici.biSize);
     if (hr != 0) {
        this.name = ici.szDescription;
        // Check quality support
        bool supportsQuality = (ici.dwFlags & Avi32Interop.VIDCF_QUALITY) == Avi32Interop.VIDCF_QUALITY;
        if (supportsQuality) {
           if (Avi32Interop.ICERR_OK == Avi32Interop.ICGetDefaultQuality(hic, ref this.quality)) {
              this.supportsQuality = true;
           }
        }
        else {
           this.quality = defaultQuality;
        }
        this.fccHandler = fccHandler;
        this.fccHandlerString = FccHandlerToString(fccHandler);
     }
     else {
        throw new AviException("ICGetInfo", hr);
     }
      }
      finally {
     Avi32Interop.ICClose(hic);
      }
 }