我正在尝试使用我在网上某处找到的示例以编程方式从位图生成 AVI 文件(不记得确切的来源)。
这是我获取选项的代码
unsafe private void SetOptions() {
AVICOMPRESSOPTIONS opts = new AVICOMPRESSOPTIONS();
opts.fccType = 0; //fccType_;
opts.fccHandler = 541215044;//0;//fccHandler_;
opts.dwKeyFrameEvery = 0;
opts.dwQuality = 0; // 0 .. 10000
opts.dwFlags = 8;//0; // AVICOMRPESSF_KEYFRAMES = 4
opts.dwBytesPerSecond = 0;
opts.lpFormat = (System.IntPtr)0; //new IntPtr(0);
opts.cbFormat = 0;
opts.lpParms = (System.IntPtr)0; //new IntPtr(0);
opts.cbParms = 3232;//0;
opts.dwInterleaveEvery = 0;
AVICOMPRESSOPTIONS* p = &opts;
AVICOMPRESSOPTIONS** pp = &p;
IntPtr x = ps_;
IntPtr* ptr_ps = &x;
AVISaveOptions(0,0,1,ptr_ps,pp);
// TODO: AVISaveOptionsFree(...)
int hr = AVIMakeCompressedStream(out psCompressed_, ps_, ref opts, 0);
if (hr != 0) {
throw new AviException("AVIMakeCompressedStream");
}
BITMAPINFOHEADER bi = new BITMAPINFOHEADER();
bi.biSize = 40;
bi.biWidth = (Int32) width_;
bi.biHeight = (Int32) height_;
bi.biPlanes = 1;
bi.biBitCount = 24;
bi.biCompression = 0; // 0 = BI_RGB
bi.biSizeImage = stride_*height_;
bi.biXPelsPerMeter= 0;
bi.biYPelsPerMeter= 0;
bi.biClrUsed = 0;
bi.biClrImportant = 0;
hr = AVIStreamSetFormat(psCompressed_, 0, ref bi, 40);
if (hr != 0) {
throw new AviException("AVIStreamSetFormat",hr);
}
}
但是,我不想显示 AVISaveOptions 对话框,并且更愿意在后端完成所有操作,我已经搜索了几个小时,但到目前为止,除了这个之外没有任何帮助:https://groups.google。 com/forum/#!topic/microsoft.public.win32.programmer.mmedia/jH0d3H2orOo
所以我的问题是,我将如何在不显示对话框的情况下进行此操作,和/或如何以编程方式填充压缩选项?