我找到了一种从BMP文件中编写avi的方法:
http
:
//www.delphi3000.com/articles/article_2770.asp?SC =我想从TBitmaps的数组或TList中编写avi?
您链接到代码的关键部分是以下,其中IList是一个TStrings与所有的文件的名称在动画中包含的.
for i := 0 to IList.Count - 1 do begin
AssignFile(BFile, IList[i]);
Reset(BFile, 1);
Seek(BFile, m_bfh.bfOffBits);
BlockRead(BFile, m_MemBits[0], m_Bih.biSizeImage);
Seek(BFile, SizeOf(m_Bfh));
BlockRead(BFile, m_MemBitMapInfo[0], length(m_MemBitMapInfo));
CloseFile(BFile);
if AVIStreamWrite(psCompressed, i, 1, @m_MemBits[0],
m_Bih.biSizeImage, AVIIF_KEYFRAME, 0, 0) <> 0 then begin
ShowMessage('Error during Write AVI File');
break;
end;
end;
Run Code Online (Sandbox Code Playgroud)
它从磁盘读取文件的一部分并将它们写入AVI流.重要的是它从文件中读取.a的内存中表示TBitmap不一定与文件的表示匹配.但是,很容易调整给定代码以将位图临时存储在存储器流中; 流将匹配文件的布局.假设IList现在是一个数组TBitmap,正如你的建议.然后我们可以用这个:
var
ms: TMemoryStream;
ms := TMemoryStream.Create;
try
for i := 0 to Length(IList) - 1 do begin
IList[i].SaveToStream(ms);
ms.Position := m_bfh.bfOffBits;
ms.ReadBuffer(m_MemBits[0], m_Bih.biSizeImage);
ms.Position := SizeOf(m_Bfh);
ms.ReadBuffer(m_MemBitMapInfo[0], Length(m_MemBitMapInfo));
ms.Clear;
if AVIStreamWrite(psCompressed, i, 1, @m_MemBits[0],
m_Bih.biSizeImage, AVIIF_KEYFRAME, 0, 0) <> 0 then begin
ShowMessage('Error during Write AVI File');
break;
end;
end;
finally
ms.Free;
end;
Run Code Online (Sandbox Code Playgroud)
在您引用的示例中,前面的代码读取列表中的第一个文件以填充各种记录并调整此处使用的数组的大小,但您应该能够像我对此处显示的代码所做的那样进行相同的更改.
| 归档时间: |
|
| 查看次数: |
1518 次 |
| 最近记录: |