帮帮忙AVI是怎样的格式?我给100分谢谢! MSDN索引AVIfile samples (DIB sequence file handler),是个com,里面的函数可以实现,用mmio函数,你可以看看怎么做的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 BMP是图片 AVI是视频,转换是没有什么意义的如果就一些图片的话,还不如合成成GIFmmio函数也没有处理这种东西的 发表意见之前最好先看看,这是它的其中一个func:HRESULT NEAR PASCAL CAVIFile::LoadFrame(LONG lPos){ char ach[_MAX_PATH]; HMMIO hmmio; BITMAPFILEHEADER bfh; BITMAPINFOHEADER bih; SCODE sc = 0; UINT ui; // // Check if we've already loaded this frame... // if (lPos == lCurFrame) return 0; // // Build the filename by printing using our template // wsprintf(ach, achFilenameTemplate, dwFirstFrame + lPos); // No system error box, please. ui = SetErrorMode(SEM_NOOPENFILEERRORBOX); // // Go try to read the frame... Because of SHARE we have to try // opening it two different ways. // hmmio = mmioOpen(ach, NULL, MMIO_READ | OF_SHARE_DENY_WRITE); if (!hmmio) { hmmio = mmioOpen(ach, NULL, MMIO_READ); if (!hmmio) return ResultFromScode(AVIERR_FILEOPEN); } SetErrorMode(ui); // // Read the BitmapFileHeader... // if (mmioRead(hmmio, (LPSTR) &bfh, sizeof(bfh)) != sizeof(bfh)) { sc = AVIERR_FILEREAD; goto error; } if (bfh.bfType != BFT_BITMAP) { sc = AVIERR_BADFORMAT; goto error; } // // Read the BitmapInfoHeader... // if (mmioRead(hmmio, (LPSTR) &bih, sizeof(bih)) != sizeof(bih)) { sc = AVIERR_FILEREAD; goto error; } if (bih.biSize < sizeof(bih)) { sc = AVIERR_BADFORMAT; goto error; } // Check that the width and height match.... if ((finfo.dwWidth && finfo.dwWidth != (DWORD) bih.biWidth) || (finfo.dwHeight && finfo.dwHeight != (DWORD) bih.biHeight)) { sc = AVIERR_BADFORMAT; goto error; } // Fix up some fields in the header... if (bih.biSizeImage == 0) { bih.biSizeImage = DIBWIDTHBYTES(bih) * bih.biHeight; } if (bih.biClrUsed == 0 && bih.biBitCount <= 8 && bih.biCompression <= BI_RLE8) bih.biClrUsed = 1 << bih.biBitCount; cbFormat = bih.biSize + bih.biClrUsed * sizeof(RGBQUAD); // Allocate space for the format if (cbFormat > cbFormatBuffer) { if (lpFormat) { GlobalFreePtr(lpFormat); lpFormat = 0; cbFormatBuffer = 0; } lpFormat = GlobalAllocPtr(GMEM_MOVEABLE | GMEM_DDESHARE, cbFormat); if (!lpFormat) { sc = AVIERR_MEMORY; goto error; } cbFormatBuffer = cbFormat; } *((LPBITMAPINFOHEADER) lpFormat) = bih; // If the format is bigger than a BITMAPINFOHEADER, read the rest.... if (cbFormat > sizeof(bih)) { if (mmioRead(hmmio, (LPSTR) lpFormat + sizeof(bih), cbFormat - (LONG)sizeof(bih)) != cbFormat - (LONG)sizeof(bih)) { sc = AVIERR_FILEREAD; goto error; } } // // Allocate enough space to read the frame in... // if (bih.biSizeImage > (DWORD) cbFrameBuffer) { if (lpFrame) { GlobalFreePtr(lpFrame); lpFrame = 0; cbFrameBuffer = 0; } lpFrame = GlobalAllocPtr(GMEM_MOVEABLE | GMEM_DDESHARE, bih.biSizeImage); if (!lpFrame) { sc = AVIERR_MEMORY; goto error; } cbFrameBuffer = bih.biSizeImage; } cbFrame = bih.biSizeImage; // // and actually read the frame.... // if (mmioRead(hmmio, (LPSTR) lpFrame, cbFrame) != cbFrame) { sc = AVIERR_FILEREAD; goto error; } lCurFrame = lPos;error: mmioClose(hmmio, 0); return ResultFromScode(sc);}当然实现不只这一个func,转换为什么没有意义?只要有目的就有意义,使用mmio并不是说mmio直接支持,如果是AVI->BMP直接用AVI func就可以实现,我有改MSDN AVIEdit sample实现这个功能。 你要看格式可以看MSDN中的AVI RIFF File Reference,AVI是RIFF(资源交互文件格式)和WAV是一类,也可以到wotsit.org找找,有AVI和RIFF的介绍。 那只有对一帧的处理,对于编辑AVI有很大用处。但是如果我给你10幅图片,让你转换成AVI,你怎么个想法呢。我不是说这个函数没有意思,我是说单单是转换几个图片是没有意义的。你看他的问题,想把BMP转换成AVI,如果AVI只有几帧的话,还能称为AVI么。 关于opencv图片的裁剪 单文档窗口最大化后,获取除去工具栏,菜单条,状态条之外的窗口大小 CListCtrl的滚动条怎么来绘制呢 如何截获 content-Disposition 方式的文件下载 CStdioFile类对文件的操作 help me:如何在一个windows 服务程序中加界面 候捷的《Win32多线程程序设计 如何动态的监视内存中运行程序的变化??100分!! 简单问题:如何去掉MDI窗口的菜单条?(帖主一直在线,问题解决,立马给分) SuperReport.lib 源码 如何用Socket传输文件(最好有源代码)? 请问在C++中多维数组是如何存储的?
如果就一些图片的话,还不如合成成GIFmmio函数也没有处理这种东西的
HRESULT NEAR PASCAL CAVIFile::LoadFrame(
LONG lPos)
{
char ach[_MAX_PATH];
HMMIO hmmio;
BITMAPFILEHEADER bfh;
BITMAPINFOHEADER bih;
SCODE sc = 0;
UINT ui; //
// Check if we've already loaded this frame...
//
if (lPos == lCurFrame)
return 0; //
// Build the filename by printing using our template
//
wsprintf(ach, achFilenameTemplate, dwFirstFrame + lPos); // No system error box, please.
ui = SetErrorMode(SEM_NOOPENFILEERRORBOX); //
// Go try to read the frame... Because of SHARE we have to try
// opening it two different ways.
//
hmmio = mmioOpen(ach, NULL, MMIO_READ | OF_SHARE_DENY_WRITE);
if (!hmmio) {
hmmio = mmioOpen(ach, NULL, MMIO_READ);
if (!hmmio)
return ResultFromScode(AVIERR_FILEOPEN);
} SetErrorMode(ui); //
// Read the BitmapFileHeader...
//
if (mmioRead(hmmio, (LPSTR) &bfh, sizeof(bfh)) != sizeof(bfh)) {
sc = AVIERR_FILEREAD;
goto error;
} if (bfh.bfType != BFT_BITMAP) {
sc = AVIERR_BADFORMAT;
goto error;
} //
// Read the BitmapInfoHeader...
//
if (mmioRead(hmmio, (LPSTR) &bih, sizeof(bih)) != sizeof(bih)) {
sc = AVIERR_FILEREAD;
goto error;
} if (bih.biSize < sizeof(bih)) {
sc = AVIERR_BADFORMAT;
goto error;
} // Check that the width and height match....
if ((finfo.dwWidth && finfo.dwWidth != (DWORD) bih.biWidth) ||
(finfo.dwHeight && finfo.dwHeight != (DWORD) bih.biHeight)) {
sc = AVIERR_BADFORMAT;
goto error;
} // Fix up some fields in the header...
if (bih.biSizeImage == 0) {
bih.biSizeImage = DIBWIDTHBYTES(bih) * bih.biHeight;
} if (bih.biClrUsed == 0 && bih.biBitCount <= 8 && bih.biCompression <= BI_RLE8)
bih.biClrUsed = 1 << bih.biBitCount; cbFormat = bih.biSize + bih.biClrUsed * sizeof(RGBQUAD); // Allocate space for the format
if (cbFormat > cbFormatBuffer) {
if (lpFormat) {
GlobalFreePtr(lpFormat);
lpFormat = 0;
cbFormatBuffer = 0;
} lpFormat = GlobalAllocPtr(GMEM_MOVEABLE | GMEM_DDESHARE, cbFormat);
if (!lpFormat) {
sc = AVIERR_MEMORY;
goto error;
} cbFormatBuffer = cbFormat;
} *((LPBITMAPINFOHEADER) lpFormat) = bih; // If the format is bigger than a BITMAPINFOHEADER, read the rest....
if (cbFormat > sizeof(bih)) {
if (mmioRead(hmmio, (LPSTR) lpFormat + sizeof(bih),
cbFormat - (LONG)sizeof(bih))
!= cbFormat - (LONG)sizeof(bih))
{
sc = AVIERR_FILEREAD;
goto error;
}
} //
// Allocate enough space to read the frame in...
//
if (bih.biSizeImage > (DWORD) cbFrameBuffer) {
if (lpFrame) {
GlobalFreePtr(lpFrame);
lpFrame = 0;
cbFrameBuffer = 0;
} lpFrame = GlobalAllocPtr(GMEM_MOVEABLE | GMEM_DDESHARE, bih.biSizeImage);
if (!lpFrame) {
sc = AVIERR_MEMORY;
goto error;
} cbFrameBuffer = bih.biSizeImage;
} cbFrame = bih.biSizeImage; //
// and actually read the frame....
//
if (mmioRead(hmmio, (LPSTR) lpFrame, cbFrame) != cbFrame) {
sc = AVIERR_FILEREAD;
goto error;
} lCurFrame = lPos;error:
mmioClose(hmmio, 0); return ResultFromScode(sc);
}当然实现不只这一个func,转换为什么没有意义?只要有目的就有意义,使用mmio并不是说mmio直接支持,如果是AVI->BMP直接用AVI func就可以实现,我有改MSDN AVIEdit sample实现这个功能。
但是如果我给你10幅图片,让你转换成AVI,你怎么个想法呢。
我不是说这个函数没有意思,我是说单单是转换几个图片是没
有意义的。你看他的问题,想把BMP转换成AVI,如果AVI只有
几帧的话,还能称为AVI么。