TLzrw1 compresseses a file with : |
---|
either the LZRW1/KH compression algorithm, with code posted by Kurt Haenen on the SWAG (lzrw1). |
or the Japanese LZH compression algorithm
|
Visual feedback ((de)compression progress status) on a Panel if so desired. |
From this moment on you can excercize the test application compressp.dpr. Or you can play with the "tlzrw1" component itself.
There are three modes of compression :
constructor Create(AOwner : TComponent); override;
The component can provide visual feedback on a panel if visible := True. So all properties/methods/events of Tpanel apply.
Only the properties applicable to the LZRW part of the component are listed here, not those of Tpanel.
The (de)compressed file when UseStream is False.
The stream to be (de)compressed. Can be any descendant of TStream that implements Read, Write and Seek. You are responsible for positioning the stream before and after compression. Used instead of InputFile when UseStream is True.
The stream that the (de)compressed result gets written to. Can be any descendant of TStream that implements Read, Write and Seek. You are responsible for positioning the stream before and after compression. Used instead of OutputFile when UseStream is True.
This property should be set prior to calling the Compress method.
Possible values : Good (default, LZH), Fast (LZRW1/KH), or Auto.
It is also returned by the Advise method.
When you set the visible property to True, TLzrw1 shows itself as a "statuspanel" on your form, that gives a visible progress indication when (de)compressing. The progress indicator is text-mode only, not a graphic gauge.
When you set the UseStream property to True, TLzrw1 will use the InputStream and OutputStream properties to read and write, instead of using the InputFile and OutputFile properties.
Specify the compression ratio (default is 40 %) that the Advise method and the compression with CompressMode = Auto use to choose between Fast (LZRW1/KH) and Good (LZH) compression. If compression with LZRW1/KH reduces the file size to more than Threshold (default 40) percent of it's original size, then Fast is advised or used.
This function compresses the file specified in the Inputfile property to the file specified in the Outputfile property using the compression algorithm chosen in Compressmode property.
The return value is either the compressed file size if all goes well, or -1 if not.
This function decompresses the file specified in the Inputfile property to the file specified in the Outputfile property using the algorithm used when compressing the file.
The return value is either the uncompressed file size, or -1 if something goes wrong.
This function compresses a block at 1/3 of the file, and one at 2/3 of the file. If the combined compression ratio reduces the file size to more then Threshold (default 40) %, the fast (LZRW1/KH) compression method is advised by returning the "Fast" TCompressMode, otherwise "Good" is returned.
all VCL code by D. Heijl , may 8-9 1996
The Getblock/PutBlock procedures are based on the code in lzhtest.pas by Douglas Webb.
The files lzh.pas and lzrw1kh.pas are essentially untouched (only some cosmetic changes, also added exceptions)
Bug discovered in LZRW1KH code by Dominque Willems, fixed may 97, Danny Heijl
Stream support added by Stefan Westner, modified slightly by Danny Heijl (May 1997). You can use any stream that implements the Read, Write and Seek methods.
I Also added a new "Threshold" property, and discovered that I introduced a new bug with the fix of 1.01.01 (signaled by David Mok
Component made thread-safe by "Paul Gertzen"
Feel free to use or give away this software as you see fit. Just leave the credits in place if you alter the source.
This software is delivered to you "as is", i.e. no guarantees, it may blow up or trigger World War Three for all I know.
If you find any bugs and let me know, I will try to fix them. If you have good suggestions or made some useful changes, please post them to me, and I will incorporate them in a future release.
I believe in programmers around the world helping each other out by distributing free source code.
Reinventing the wheel can be a lot of fun, but is not always the best way to handle things. Also, someone else may have come up with an idea for much better wheels.
Danny Heijl, may 10 1996.
[email protected]