|  3DSoftware.com > Programming > Compression > ZLib |
|
Lossless Compression
An effective method of lossless compression is implemented with the ZLib Library for ZLib Library The ZLib programming library was designed for embedded systems computers (microcontrollers) which require small memory footprint. For general purpose computing you need to write a wrapper to handle the memory management in accumulation loop fashion, as covered in the ZLib Usage article. ZLib is written in the C language and is very portable. To port to C++, simply change the filename extensions of the source code files as needed, and change any old style C function declarations (your compiler will report each one as an error) to the new C++ style function declarations. For example, this is an old style C function declaration: |
|
|
||
|
If your compiler reports that as an error, change that to: |
||
|
||
|
Porting to C++ also requires that you change the name of one of the variables (name of a record). What happened is that the ZLib source code (written in C) names a record (struct) this. In C you can do that, but in C++ this is a reserved name. When you port ZLib to C++ your compiler will report an error wherever this is used as a variable name. All you have to do is change that variable name. You can change it to This since reserved names are only lower case. Here is an example from the ZLib source code ported to C++: |
||
|
||
|
In that source code, |
||
|
To perform in-memory processing instead of writing to disk, allocate a memory block each time data made available, and keep a list of pointers to the allocated memory blocks. After processing, use the memory blocks in order, and free each one when done. |
|
Copyright © 2008 by 3D Software. All rights reserved. 3D Software, P.O. Box 221190, Sacramento CA 95822 USA www.3DSoftware.com Contact us |
| Thursday, 20-Nov-2008 12:38:20 GMT |