MityDSP Documentation Index

ZLib Library

Using Zlib with MityDSP

The ZLib library provides a very thin wrapper around the open source zlib (version 1.2.3) compression utilities. For complete sources of the zlib libraries, please reference the code online at http://www.zlib.net/ or contact Critical Link for a copy of the software used to build the library.

This implementation of Zlib is compiled to support decoding and encoding gzip style headers (see RFC 1952). This unit has been tested to inflate gzip compressed files loaded into memory as well as compressing/uncompressing RAW image data using the methods wrapped in the ZLib namespace.

Note:
The port of this library has not been fully tested, only those features wrapped by the ZLib namespace are known to be functional. Users electing to leverage the zlib.h interface do so at their own risk.

Example code that could be used to extract a gzip compressed image into memory is shown in the code segment below.

  {
  void UnCompressGZIP(unsigned char* Addr, int Length, char* out, int OutLength)
  {
     unsigned char* Addr = GZIP_IMAGE_ADDR;
     unsigned int   Length = GZIP_IMAGE_LENGTH;
     unsigned char* out;
     unsigned int   OutLength = INFLATED_LENGTH;  // Output length, could be stored, also
                                                  // can be read from GZIP file (last integer in file)
                                                  // can also be made "big" and get actual size later,
                                                  // (this would require cleaning up unused memory...)
     unsigned int   iflength = OutLength;         // inflated length
     int rv;

     out = new unsigned char[OutLength];

     rv = UnCompress(out, &OutLength, (unsigned char*)Addr, Length);
    
     if (rv == eeOK)
     { 
        // iflength is actual uncompressed size
        // out contains image data
     }

     delete [] heap;
 } 

  
Generated on Wed Mar 17 18:24:41 2010 for Zlib Compression Library by  Doxygen Version 1.6.1
Copyright © 2009, Critical Link LLC, All rights reserved.