![]() |
Leptonica
1.82.0
Image processing and image analysis suite
|
#include <string.h>
#include "allheaders.h"
Go to the source code of this file.
Macros | |
#define | DEBUG_SERIALIZE 0 |
Functions | |
PIX * | pixReadStreamSpix (FILE *fp) |
l_ok | readHeaderSpix (const char *filename, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap) |
l_ok | freadHeaderSpix (FILE *fp, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap) |
l_ok | sreadHeaderSpix (const l_uint32 *data, size_t size, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap) |
l_ok | pixWriteStreamSpix (FILE *fp, PIX *pix) |
PIX * | pixReadMemSpix (const l_uint8 *data, size_t size) |
l_ok | pixWriteMemSpix (l_uint8 **pdata, size_t *psize, PIX *pix) |
l_ok | pixSerializeToMemory (PIX *pixs, l_uint32 **pdata, size_t *pnbytes) |
PIX * | pixDeserializeFromMemory (const l_uint32 *data, size_t nbytes) |
Variables | |
static const l_int32 | MaxAllowedWidth = 1000000 |
static const l_int32 | MaxAllowedHeight = 1000000 |
static const l_int64 | MaxAllowedArea = 400000000LL |
This does fast serialization of a pix in memory to file, copying the raw data for maximum speed. The underlying function serializes it to memory, and it is wrapped to be callable from standard pixRead() and pixWrite() file functions. Reading spix from file PIX *pixReadStreamSpix() l_int32 readHeaderSpix() l_int32 freadHeaderSpix() l_int32 sreadHeaderSpix() Writing spix to file l_int32 pixWriteStreamSpix() Low-level serialization of pix to/from memory (uncompressed) PIX *pixReadMemSpix() l_int32 pixWriteMemSpix() l_int32 pixSerializeToMemory() PIX *pixDeserializeFromMemory() Note: these functions have not been extensively tested for fuzzing (bad input data that can result in, e.g., memory faults). The spix serialization format is only defined here, in leptonica. The image data is uncompressed and the serialization is not intended to be a secure file format from untrusted sources.
Definition in file spixio.c.
l_ok freadHeaderSpix | ( | FILE * | fp, |
l_int32 * | pwidth, | ||
l_int32 * | pheight, | ||
l_int32 * | pbps, | ||
l_int32 * | pspp, | ||
l_int32 * | piscmap | ||
) |
[in] | fp | file stream |
[out] | pwidth | width |
[out] | pheight | height |
[out] | pbps | bits/sample |
[out] | pspp | samples/pixel |
[out] | piscmap | [optional] input NULL to ignore |
Notes: (1) If there is a colormap, iscmap is returned as 1; else 0.
Definition at line 171 of file spixio.c.
References fnbytesInFile(), and sreadHeaderSpix().
Referenced by readHeaderSpix().
PIX* pixDeserializeFromMemory | ( | const l_uint32 * | data, |
size_t | nbytes | ||
) |
[in] | data | serialized data in memory |
[in] | nbytes | number of bytes in data string |
Notes: (1) See pixSerializeToMemory() for the binary format. (2) Note the image size limits.
Definition at line 436 of file spixio.c.
Referenced by pixReadMemSpix().
PIX* pixReadMemSpix | ( | const l_uint8 * | data, |
size_t | size | ||
) |
[in] | data | const; uncompressed |
[in] | size | bytes of data |
Definition at line 305 of file spixio.c.
References pixDeserializeFromMemory().
Referenced by pixReadStreamSpix().
PIX* pixReadStreamSpix | ( | FILE * | fp | ) |
[in] | fp | file stream |
Notes: (1) If called from pixReadStream(), the stream is positioned at the beginning of the file.
Definition at line 92 of file spixio.c.
References l_binaryReadStream(), and pixReadMemSpix().
l_ok pixSerializeToMemory | ( | PIX * | pixs, |
l_uint32 ** | pdata, | ||
size_t * | pnbytes | ||
) |
[in] | pixs | all depths, colormap OK |
[out] | pdata | serialized data in memory |
[out] | pnbytes | number of bytes in data string |
Notes: (1) This does a fast serialization of the principal elements of the pix, as follows: "spix" (4 bytes) -- ID for file type w (4 bytes) h (4 bytes) d (4 bytes) wpl (4 bytes) ncolors (4 bytes) -- in colormap; 0 if there is no colormap cdata (4 * ncolors) -- size of serialized colormap array rdatasize (4 bytes) -- size of serialized raster data = 4 * wpl * h rdata (rdatasize)
Definition at line 354 of file spixio.c.
References pixGetDimensions().
Referenced by pixWriteMemSpix().
l_ok pixWriteMemSpix | ( | l_uint8 ** | pdata, |
size_t * | psize, | ||
PIX * | pix | ||
) |
[out] | pdata | data of serialized, uncompressed pix |
[out] | psize | size of returned data |
[in] | pix | all depths; colormap OK |
Definition at line 321 of file spixio.c.
References pixSerializeToMemory().
Referenced by pixWriteStreamSpix().
l_ok pixWriteStreamSpix | ( | FILE * | fp, |
PIX * | pix | ||
) |
[in] | fp | file stream |
[in] | pix |
Definition at line 273 of file spixio.c.
References pixWriteMemSpix().
l_ok readHeaderSpix | ( | const char * | filename, |
l_int32 * | pwidth, | ||
l_int32 * | pheight, | ||
l_int32 * | pbps, | ||
l_int32 * | pspp, | ||
l_int32 * | piscmap | ||
) |
[in] | filename | |
[out] | pwidth | width |
[out] | pheight | height |
[out] | pbps | bits/sample |
[out] | pspp | samples/pixel |
[out] | piscmap | [optional] input NULL to ignore |
Notes: (1) If there is a colormap, iscmap is returned as 1; else 0.
Definition at line 130 of file spixio.c.
References fopenReadStream(), and freadHeaderSpix().
l_ok sreadHeaderSpix | ( | const l_uint32 * | data, |
size_t | size, | ||
l_int32 * | pwidth, | ||
l_int32 * | pheight, | ||
l_int32 * | pbps, | ||
l_int32 * | pspp, | ||
l_int32 * | piscmap | ||
) |
[in] | data | |
[in] | size | of data |
[out] | pwidth | width |
[out] | pheight | height |
[out] | pbps | bits/sample |
[out] | pspp | samples/pixel |
[out] | piscmap | [optional] input NULL to ignore |
Notes: (1) If there is a colormap, iscmap is returned as 1; else 0.
Definition at line 216 of file spixio.c.
Referenced by freadHeaderSpix().