Delphi Database, Delphi Components from ComponentAce
Products Download Order Contact us
/img/help/home.gif /img/help/prev.gif /img/help/next.gif

 

Changing compression level

 


 

TECLFileStream and TECLMemoryStream provide you a really easy way to change a compression level. All you need to do is to set CompressionLevel property of the stream to a new value.

When CompressionLevel of TECLFileStream is set to eclNone, TECLFileStream doesn't save internal headers to file and completely equal to the TFileStream class.

 

This process may take a long time for large data, so it is recommended to indicate a progress during this operation.

 

The following example demonstrates how to compress a file to file and then change its compression level.

Example:

var

CompFS: TECLFileStream;

begin

{ create compressed file }

CompFS := TECLFileStream.Create('c:\test_comp.ecl', fmCreate, '', zlibFastest);

{ load and compress data from test.txt file}

CompFS.LoadFromFile('c:\test.txt');

{ show the size of compressed data }

ShowMessage('Size of file compressed in zlibFastest mode: '+IntToStr(CompFS.PackedSize));

{ close compressed file }

CompFS.Free;

 

{ open compressed file }

CompFS := TECLFileStream.Create('c:\test_comp.ecl', fmOpenReadWrite or fmShareDenyNone);

{ change compression level }

CompFS.CompressionLevel := ppmMax;

{ show the size of compressed data }

ShowMessage('Size of file compressed in ppmMax mode: '+IntToStr(CompFS.PackedSize));

{ close compressed file }

CompFS.Free;

end;

 

        © 2003 - 2024 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Nov 21, 2024