Thema: Delphi zlib

Einzelnen Beitrag anzeigen

e-dancer

Registriert seit: 21. Feb 2003
28 Beiträge
 
Delphi 6 Personal
 
#2
  Alt 21. Feb 2003, 23:37
Delphi-Quellcode:
uses ZLib, SysUtils;
Packen:
procedure Compress(InputFileName, OutputFileName: string);
var InputStream, OutputStream: TFileStream;
  CompressionStream: ZLib.TCompressionStream;
begin
  InputStream:=TFileStream.Create(InputFileName, fmOpenRead);
  try
    OutputStream:=TFileStream.Create(OutputFileName, fmCreate);
    try
      CompressionStream:=TCompressionStream.Create(clMax, OutputStream);
      try
        CompressionStream.CopyFrom(InputStream, InputStream.Size);
      finally
        CompressionStream.Free;
      end;
    finally
      OutputStream.Free;
    end;
  finally
    InputStream.Free;
  end;
end;

Entpacken:
procedure Decompress(InputFileName, OutputFileName: string);
var InputStream, OutputStream: TFileStream;
  DeCompressionStream: ZLib.TDeCompressionStream;
begin
  InputStream:=TFileStream.Create(InputFileName, fmOpenRead);
  try
    OutputStream:=TFileStream.Create(OutputFileName, fmCreate);
    try
      DecompressionStream:=TDecompressionStream.Create(OutputStream);
      try
        DecompressionStream.CopyFrom(InputStream, InputStream.Size);
      finally
        DecompressionStream.Free;
      end;
    finally
      OutputStream.Free;
    end;
  finally
    InputStream.Free;
  end;
end;
@e-dancer: Wir haben auch CODE-TAGS!!! Wenn du die in Zukunft bitte benutzen würdest. Die Firma dankt.- Luckie
  Mit Zitat antworten Zitat