Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Operating System Utilities /
Chapter 3 - Mathematical and Logical Utilities / Mathematical and Logical Utilities Reference
Routines / Compressing and Decompressing Data


UnpackBits

You can use the UnpackBits procedure to decompress a data buffer containing data compressed by PackBits.

PROCEDURE UnpackBits (VAR srcPtr, dstPtr: Ptr; dstBytes: Integer);
srcPtr
On entry, a pointer to the first byte of a buffer of data to be decompressed. On exit, a pointer to the first byte following the compressed data.
dstPtr
On entry, a pointer to the first byte in which to store decompressed data. On exit, a pointer to the first byte following the decompressed data.
dstBytes
The number of bytes of the data before compression. In general, you should either use PackBits to compress data structures of a fixed size that you can then pass in this parameter to UnpackBits, or store with the compressed data the original size of the uncompressed data.
DESCRIPTION
The UnpackBits procedure decompresses srcBytes bytes of data beginning at the location specified by the srcPtr parameter and stores it at the location specified by the dstPtr parameter. It then modifies the srcPtr and dstPtr variables to point to the first bytes after the compressed and decompressed data, respectively.

Because your application must allocate memory for the source and destination buffers, UnpackBits does not move relocatable blocks. Thus, you can call it at interrupt time.

SPECIAL CONSIDERATIONS
Because UnpackBits changes the values of the srcPtr and dstPtr parameters, you should pass to UnpackBits only copies of pointers to the source and destination buffers. This allows you to access the beginning of the source and destination buffers after UnpackBits returns. Also, if the source or destination buffer is stored in an unlocked, relocatable block, this technique prevents UnpackBits from changing the value of a master pointer, which would make the original handle invalid.

SEE ALSO
For an example of the use of the UnpackBits procedure, see Listing 3-4 on page 3-21.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996