Registriert seit: 2. Mär 2004
5.508 Beiträge
Delphi 5 Professional
|
Re: Fehlerhafte JPG Dateien Reparieren?
29. Sep 2006, 12:04
Delphi-Quellcode:
procedure WriteHeader(const FileName: string; const Header: AnsiString);
var
fs: TFileStream;
begin
fs := TFileStream.Create(FileName, fmOpenReadWrite);
try
fs.WriteBuffer(Header[1], Length(Header));
finally
fs.Free;
end;
end;
Der korrekten Header lädst du am Besten aus einer Datei:
Delphi-Quellcode:
function FileToString(const FileName: string): AnsiString;
var
fs: TFileStream;
Len: Integer;
begin
fs := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
try
Len := fs.Size;
SetLength(Result, Len);
if Len > 0 then
fs.ReadBuffer(Result[1], Len);
finally
fs.Free;
end;
end;
Delphi-Quellcode:
var
header : string;
begin
header := FileToString('header.dat');
WriteHeader('kaputt.jpeg', header);
Andreas
|