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
CompFS := TECLFileStream.Create('c:\test_comp.ecl', fmCreate, '', zlibFastest);
CompFS.LoadFromFile('c:\test.txt');
ShowMessage('Size of file compressed in zlibFastest mode: '+IntToStr(CompFS.PackedSize));
CompFS.Free;
CompFS := TECLFileStream.Create('c:\test_comp.ecl', fmOpenReadWrite or fmShareDenyNone);
CompFS.CompressionLevel := ppmMax;
ShowMessage('Size of file compressed in ppmMax mode: '+IntToStr(CompFS.PackedSize));
CompFS.Free;
end;
|