![]() |
Leptonica
1.83.1
Image processing and image analysis suite
|
#include "allheaders.h"
#include "zlib.h"
Go to the source code of this file.
Macros | |
#define | DEBUG 0 |
Functions | |
l_uint8 * | zlibCompress (const l_uint8 *datain, size_t nin, size_t *pnout) |
l_uint8 * | zlibUncompress (const l_uint8 *datain, size_t nin, size_t *pnout) |
Variables | |
static const l_int32 | L_BUF_SIZE = 32768 |
static const l_int32 | ZLIB_COMPRESSION_LEVEL = 6 |
zlib operations in memory, using bbuffer l_uint8 *zlibCompress() l_uint8 *zlibUncompress() This provides an example use of the byte buffer utility (see bbuffer.c for details of how the bbuffer works internally). We use zlib to compress and decompress a byte array from one memory buffer to another. The standard method uses streams, but here we use the bbuffer as an expandable queue of pixels for both the reading and writing sides of each operation. With memory mapping, one should be able to compress between memory buffers by using the file system to buffer everything in the background, but the bbuffer implementation is more portable.
Definition in file zlibmem.c.
l_uint8* zlibCompress | ( | const l_uint8 * | datain, |
size_t | nin, | ||
size_t * | pnout | ||
) |
[in] | datain | byte buffer with input data |
[in] | nin | number of bytes of input data |
[out] | pnout | number of bytes of output data |
Notes: (1) We repeatedly read in and fill up an input buffer, compress the data, and read it back out. zlib uses two byte buffers internally in the z_stream data structure. We use the bbuffers to feed data into the fixed bufferin, and feed it out of bufferout, in the same way that a pair of streams would normally be used if the data were being read from one file and written to another. This is done iteratively, compressing L_BUF_SIZE bytes of input data at a time.
Definition at line 92 of file zlibmem.c.
References bbufferCreate(), and L_BUF_SIZE.
Referenced by l_genDataString().
l_uint8* zlibUncompress | ( | const l_uint8 * | datain, |
size_t | nin, | ||
size_t * | pnout | ||
) |
[in] | datain | byte buffer with compressed input data |
[in] | nin | number of bytes of input data |
[out] | pnout | number of bytes of output data |
Notes: (1) See zlibCompress().
Definition at line 193 of file zlibmem.c.
References bbufferCreate(), bbufferDestroy(), bbufferDestroyAndSaveData(), bbufferRead(), bbufferWrite(), L_BUF_SIZE, and lept_stderr().
Referenced by ccbaReadStream().