Software developers will inevitably have to face the problem of compressed data! Often use Delphi friends know that it provides us with two flow classes (Tcompressionstream and Tdecompressionstream) to complete the compression and decompression of data, but the drawback is that the flow in Delphi Help no detailed description , making them difficult to use. In fact, in the Delphi system provides these two classes of source code and library. Stored in the Delphi CD-ROM \info\extras\zlib\ src and \info\extras\zlib\obj directory (where the obj directory is stored in the library, SRC directory to save the source code, interested friends can see). In the process of using, I have a certain understanding of them.
I. Description of the class
1, base class Tcustomzlibstream: Class Tcustomzlibstream is the class Tcompressionstream and Tdecompressionstream class base class, it has one main attribute: OnProgress, This event occurs during the process of compressing or decompressing a class, which is defined as follows:
Procedure onprogress (Sender:tobject); Dynamic
2, Compression class Tcompressionstream: Class Tcompressionstream In addition to inheriting the OnProgress attribute of the base class, but also added a property: Compressionrate, it is defined as follows:
Property Compressionrate:single read Getcompressionrate, through which the compression ratio can be obtained.
Several of its important methods are defined as follows:
Constructor Tcompressionstream.create (Compressionlevel:tcompressionlevel; Dest:tstream);
Where: Tcompressionlevel (compression type), which is defined by the following:
①, Clnone: no data compression;
②, Clfastest: Fast compression, sacrificing compression efficiency;
③, Cldefault: normal compression;
④, CLmax: To maximize compression, sacrificing speed;
Dest: Destination stream, for storing compressed data.