Leptonica 1.68
C Image Processing Library
|
Fast pix serialization to/from file. More...
Go to the source code of this file.
Functions | |
PIX * | pixReadStreamSpix (FILE *fp) |
l_int32 | readHeaderSpix (const char *filename, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap) |
l_int32 | freadHeaderSpix (FILE *fp, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap) |
l_int32 | sreadHeaderSpix (const l_uint32 *data, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap) |
l_int32 | pixWriteStreamSpix (FILE *fp, PIX *pix) |
PIX * | pixReadMemSpix (const l_uint8 *data, size_t size) |
l_int32 | pixWriteMemSpix (l_uint8 **pdata, size_t *psize, PIX *pix) |
l_int32 | pixSerializeToMemory (PIX *pixs, l_uint32 **pdata, size_t *pnbytes) |
PIX * | pixDeserializeFromMemory (const l_uint32 *data, size_t nbytes) |
Fast pix serialization to/from file.
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 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()
Definition in file spixio.c.
PIX* pixReadStreamSpix | ( | FILE * | fp | ) |
Input: stream Return: pix, or null on error.
Notes: (1) If called from pixReadStream(), the stream is positioned at the beginning of the file.
Definition at line 59 of file spixio.c.
References ERROR_PTR, FREE, l_binaryReadStream(), NULL, pixReadMemSpix(), and PROCNAME.
Referenced by pixReadStream().
l_int32 readHeaderSpix | ( | const char * | filename, |
l_int32 * | pwidth, | ||
l_int32 * | pheight, | ||
l_int32 * | pbps, | ||
l_int32 * | pspp, | ||
l_int32 * | piscmap | ||
) |
Input: filename &width (<return>) &height (<return>) &bps (<return>, bits/sample) &spp (<return>, samples/pixel) &iscmap (<optional return>="">; input NULL to ignore) Return: 0 if OK, 1 on error
Notes: (1) If there is a colormap, iscmap is returned as 1; else 0.
Definition at line 97 of file spixio.c.
References ERROR_INT, fopenReadStream(), freadHeaderSpix(), NULL, and PROCNAME.
Referenced by pixReadHeader().
l_int32 freadHeaderSpix | ( | FILE * | fp, |
l_int32 * | pwidth, | ||
l_int32 * | pheight, | ||
l_int32 * | pbps, | ||
l_int32 * | pspp, | ||
l_int32 * | piscmap | ||
) |
Input: stream &width (<return>) &height (<return>) &bps (<return>, bits/sample) &spp (<return>, samples/pixel) &iscmap (<optional return>="">; input NULL to ignore) Return: 0 if OK, 1 on error
Notes: (1) If there is a colormap, iscmap is returned as 1; else 0.
Definition at line 136 of file spixio.c.
References CALLOC, ERROR_INT, fnbytesInFile(), FREE, NULL, PROCNAME, and sreadHeaderSpix().
Referenced by readHeaderSpix().
l_int32 sreadHeaderSpix | ( | const l_uint32 * | data, |
l_int32 * | pwidth, | ||
l_int32 * | pheight, | ||
l_int32 * | pbps, | ||
l_int32 * | pspp, | ||
l_int32 * | piscmap | ||
) |
Input: data &width (<return>) &height (<return>) &bps (<return>, bits/sample) &spp (<return>, samples/pixel) &iscmap (<optional return>="">; input NULL to ignore) Return: 0 if OK, 1 on error
Notes: (1) If there is a colormap, iscmap is returned as 1; else 0.
Definition at line 181 of file spixio.c.
References ERROR_INT, and PROCNAME.
Referenced by freadHeaderSpix(), and pixReadHeaderMem().
Input: stream pix Return: 0 if OK; 1 on error
Definition at line 236 of file spixio.c.
References ERROR_INT, FREE, pixWriteMemSpix(), PROCNAME, and size.
Referenced by pixWriteStream().
Input: data (const; uncompressed) size (of data) Return: pix, or null on error
Definition at line 268 of file spixio.c.
References pixDeserializeFromMemory().
Referenced by pixReadMem(), and pixReadStreamSpix().
Input: &data (<return> data of serialized, uncompressed pix) &size (<return> size of returned data) pix (all depths; colormap OK) Return: 0 if OK, 1 on error
Definition at line 284 of file spixio.c.
References pixSerializeToMemory().
Referenced by pixWriteMem(), and pixWriteStreamSpix().
Input: pixs (all depths, colormap OK) &data (<return> serialized data in memory) &nbytes (<return> number of bytes in data string) Return: 0 if OK, 1 on error
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 cdatasize (4 bytes) -- size of serialized colormap = 4 * (num colors) cdata (cdatasize) rdatasize (4 bytes) -- size of serialized raster data = 4 * wpl * h rdata (rdatasize)
Definition at line 317 of file spixio.c.
References CALLOC, ERROR_INT, FREE, NULL, pixcmapSerializeToMemory(), pixGetColormap(), pixGetData(), pixGetDimensions(), pixGetWpl(), and PROCNAME.
Referenced by main(), and pixWriteMemSpix().
Input: data (serialized data in memory) nbytes (number of bytes in data string) Return: pix, or NULL on error
Notes: (1) See pixSerializeToMemory() for the binary format.
Definition at line 391 of file spixio.c.
References ERROR_PTR, NULL, pixcmapDeserializeFromMemory(), pixCreate(), pixGetData(), pixSetColormap(), and PROCNAME.
Referenced by main(), and pixReadMemSpix().