Registriert seit: 3. Mär 2006
264 Beiträge
Delphi 11 Alexandria
|
Re: BMP in AVI wandeln
20. Mai 2006, 14:40
Das habe ich noch in meiner Rumpelkammer gehabt. Schon ein paar Jahre alt, nie so richtig gut, aber vielleicht kannst du damit etwas anfangen.
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var dir: String;
ts: TSearchRec;
datlist: TStringList;
tfs: TFileStream;
pfile: IAVIFile;
pavi: IAVIStream;
psi: TAVISTREAMINFO;
Bfi: BITMAPFILEHEADER;
bmi: PBITMAPINFO;
bits: PByteArray;
i, bmisize: Integer;
begin
if Not SelectDirectory('Bitmapverzeichnis wählen', 'c:\tempo', dir) then Exit;
if FindFirst(dir+'\*.bmp', faAnyFile, ts)<>0 then Exit;
if Not SaveDialog1.Execute then Exit;
datlist:=TStringList.Create;
try
datlist.Add(ts.Name);
while FindNext(ts)=0 do datlist.Add(ts.Name);
datlist.Sort;
finally
FindClose(ts);
end;
Label1.Caption:=IntToStr(datlist.Count);
tfs:=TFileStream.Create(dir+'\'+datlist[0], fmOpenRead);
tfs.Read(bfi, SizeOf(BITMAPFILEHEADER));
bmisize:=bfi.bfOffBits-SizeOf(BITMAPFILEHEADER);
GetMem(bmi, bmisize);
tfs.Read(bmi^, bmisize);
GetMem(bits, bmi.bmiHeader.biSizeImage);
tfs.Read(bits^, bmi^.bmiHeader.biSizeImage);
AVIFileInit;
AVIFileOpen(pfile, PChar(SaveDialog1.FileName), OF_CREATE OR OF_WRITE, NIL);
ZeroMemory(@psi, SizeOf(TAVIStreamInfo));
with psi do
begin
fccType:=streamtypeVIDEO;
fccHandler:=mmioFourcc(#0, 'D', 'I', 'B');
dwScale:=1;
dwRate:=25;
dwLength:=datlist.Count;
dwSuggestedBufferSize:=bmi.bmiHeader.biSizeImage;
rcFrame:=Rect(0, 0, bmi.bmiHeader.biWidth, bmi.bmiHeader.biHeight);
szName:='Noname';
dwQuality:=$FFFFFFFF;
dwSampleSize:=bmi.bmiHeader.biSizeImage;
end;
AVIFileCreateStream(pfile, pavi, psi);
AVIStreamSetFormat(pavi, 0, bmi, bmisize);
For i:=0 to datlist.Count-1 do
begin
AVIStreamWrite(pavi, i, 1, bits, bmi.bmiHeader.biSizeImage, AVIIF_KEYFRAME, NIL, NIL);
tfs.Free;
tfs:=TFileStream.Create(dir+'\'+datlist[i], fmOpenRead);
Image1.Picture.Bitmap.LoadFromStream(tfs);
tfs.Seek(bfi.bfOffBits, soFromBeginning);
tfs.Read(bits^, bmi.bmiHeader.biSizeImage);
Label2.Caption:=IntToStr(i+1);
Application.ProcessMessages;
end;
tfs.Free;
FreeMem(bits);
datlist.Free;
end;
|
|
Zitat
|