2008年7月27日 星期日

處理AVI所需的結構

namespace AVIProcess
{
 partial class AVIFileAPI
 {
  [StructLayout(LayoutKind.Sequential, Pack = 1)]
  internal struct RECT
  {
   int left;
   int top;
   int right;
   int bottom;
  }

  /// 檔案開啟模式
  internal enum FILEOPENMODE : uint
  {
   OF_READ = 0x00000000,
   OF_WRITE = 0x00000001,
   OF_READWRITE = 0x00000002,
   OF_SHARE_COMPAT = 0x00000000,
   OF_SHARE_EXCLUSIVE = 0x00000010,
   OF_SHARE_DENY_WRITE = 0x00000020,
   OF_SHARE_DENY_READ = 0x00000030,
   OF_SHARE_DENY_NONE = 0x00000040,
   OF_PARSE = 0x00000100,
   OF_DELETE = 0x00000200,
   OF_VERIFY = 0x00000400,
   OF_CANCEL = 0x00000800,
   OF_CREATE = 0x00001000,
   OF_PROMPT = 0x00002000,
   OF_EXIST = 0x00004000,
   OF_REOPEN = 0x00008000
  }

  /// AVI檔案資訊
  [StructLayout(LayoutKind.Sequential, Pack = 1)]
  unsafe internal struct AVIFILEINFO
  {
   public uint dwMaxBytesPerSec;
   public uint dwFlags;
   public uint dwCaps;
   public uint dwStreams;
   public uint dwSuggestedBufferSize;
   public uint dwWidth;
   public uint dwHeight;
   public uint dwScale;
   public uint dwRate;
   public uint dwLength;
   public uint dwEditCount;
   public fixed char szFileType[64];
  }

  /// Bitmap檔頭資訊
  [StructLayout(LayoutKind.Sequential, Pack = 1)]
  internal struct BITMAPINFOHEADER
  {
   public uint biSize;
   public int biWidth;
   public int biHeight;
   public ushort biPlanes;
   public ushort biBitCount;
   public uint biCompression;
   public uint biSizeImage;
   public int biXPelsPerMeter;
   public int biYPelsPerMeter;
   public uint biClrUsed;
   public uint biClrImportant;
  }

  /// Bitmap檔案檔頭
  [StructLayout(LayoutKind.Sequential, Pack = 1)]
  internal struct BITMAPFILEHEADER
  {
   public UInt16 bfType;
   public uint bfSize;
   public UInt16 bfReserved1;
   public UInt16 bfReserved2;
   public uint bfOffBits;
  }

  /// 資料流資訊
  [StructLayout(LayoutKind.Sequential, Pack = 1)]
  unsafe internal struct AVISTREAMINFO
  {
   public uint fccType;
   public uint fccHandler;
   public uint dwFlags;
   public uint dwCaps;
   public UInt16 wPriority;
   public UInt16 wLanguage;
   public uint dwScale;
   public uint dwRate;
   public uint dwStart;
   public uint dwLength;
   public uint dwInitialFrames;
   public uint dwSuggestedBufferSize;
   public uint dwQuality;
   public uint dwSampleSize;
   RECT rcFrame;
   public uint dwEditCount;
   public uint dwFormatChangeCount;
   public fixed char szName[64];
  } 

  internal static uint mmioFOURCC(char c0, char c1, char c2, char c3)
  {
   return (uint)c0 | ((uint)c1) << 8 | ((uint)c2) << 16 | ((uint)c3) << 24;
  }

  internal static readonly uint streamtypeVIDEO = mmioFOURCC('v', 'i', 'd', 's');
  internal static readonly uint streamtypeAUDIO = mmioFOURCC('a', 'u', 'd', 's');
  internal static readonly uint streamtypeMIDI = mmioFOURCC('m', 'i', 'd', 's');
  internal static readonly uint streamtypeTEXT = mmioFOURCC('t', 'x', 't', 's');

  internal const int AVIGETFRAMEF_BESTDISPLAYFMT = 1;

 }
}

沒有留言:

張貼留言