Leptonica  1.54
Файл spixio.c
#include <string.h>
#include "allheaders.h"

Макросы

#define DEBUG_SERIALIZE   0
 

Функции

PIXpixReadStreamSpix (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)
 
PIXpixReadMemSpix (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)
 
PIXpixDeserializeFromMemory (const l_uint32 *data, size_t nbytes)
 

Переменные

static const l_int32 L_MAX_ALLOWED_WIDTH = 1000000
 
static const l_int32 L_MAX_ALLOWED_HEIGHT = 1000000
 
static const l_int64 L_MAX_ALLOWED_AREA = 400000000LL
 

Макросы

◆ DEBUG_SERIALIZE

#define DEBUG_SERIALIZE   0

Функции

◆ freadHeaderSpix()

l_int32 freadHeaderSpix ( FILE *  fp,
l_int32 pwidth,
l_int32 pheight,
l_int32 pbps,
l_int32 pspp,
l_int32 piscmap 
)

freadHeaderSpix()

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.

◆ pixDeserializeFromMemory()

PIX* pixDeserializeFromMemory ( const l_uint32 data,
size_t  nbytes 
)

pixDeserializeFromMemory()

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. (2) Note the image size limits.

◆ pixReadMemSpix()

PIX* pixReadMemSpix ( const l_uint8 data,
size_t  size 
)

pixReadMemSpix()

Input:  data (const; uncompressed)
        size (of data)
Return: pix, or null on error

◆ pixReadStreamSpix()

PIX* pixReadStreamSpix ( FILE *  fp)

pixReadStreamSpix()

Input:  stream
Return: pix, or null on error.

Notes: (1) If called from pixReadStream(), the stream is positioned at the beginning of the file.

◆ pixSerializeToMemory()

l_int32 pixSerializeToMemory ( PIX pixs,
l_uint32 **  pdata,
size_t *  pnbytes 
)

pixSerializeToMemory()

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 cdata (4 * ncolors) – size of serialized colormap array rdatasize (4 bytes) – size of serialized raster data = 4 * wpl * h rdata (rdatasize)

◆ pixWriteMemSpix()

l_int32 pixWriteMemSpix ( l_uint8 **  pdata,
size_t *  psize,
PIX pix 
)

pixWriteMemSpix()

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

◆ pixWriteStreamSpix()

l_int32 pixWriteStreamSpix ( FILE *  fp,
PIX pix 
)

pixWriteStreamSpix()

Input:  stream
        pix
Return: 0 if OK; 1 on error

◆ readHeaderSpix()

l_int32 readHeaderSpix ( const char *  filename,
l_int32 pwidth,
l_int32 pheight,
l_int32 pbps,
l_int32 pspp,
l_int32 piscmap 
)

readHeaderSpix()

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.

◆ sreadHeaderSpix()

l_int32 sreadHeaderSpix ( const l_uint32 data,
l_int32 pwidth,
l_int32 pheight,
l_int32 pbps,
l_int32 pspp,
l_int32 piscmap 
)

sreadHeaderSpix()

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.

Переменные

◆ L_MAX_ALLOWED_AREA

const l_int64 L_MAX_ALLOWED_AREA = 400000000LL
static

◆ L_MAX_ALLOWED_HEIGHT

const l_int32 L_MAX_ALLOWED_HEIGHT = 1000000
static

◆ L_MAX_ALLOWED_WIDTH

const l_int32 L_MAX_ALLOWED_WIDTH = 1000000
static