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

Функции

static l_int32 pnmReadNextAsciiValue (FILE *fp, l_int32 *pval)
static l_int32 pnmSkipCommentLines (FILE *fp)
PIXpixReadStreamPnm (FILE *fp)
l_int32 readHeaderPnm (const char *filename, PIX **ppix, l_int32 *pwidth, l_int32 *pheight, l_int32 *pdepth, l_int32 *ptype, l_int32 *pbps, l_int32 *pspp)
l_int32 freadHeaderPnm (FILE *fp, PIX **ppix, l_int32 *pwidth, l_int32 *pheight, l_int32 *pdepth, l_int32 *ptype, l_int32 *pbps, l_int32 *pspp)
l_int32 pixWriteStreamPnm (FILE *fp, PIX *pix)
l_int32 pixWriteStreamAsciiPnm (FILE *fp, PIX *pix)
PIXpixReadMemPnm (const l_uint8 *cdata, size_t size)
l_int32 sreadHeaderPnm (const l_uint8 *cdata, size_t size, l_int32 *pwidth, l_int32 *pheight, l_int32 *pdepth, l_int32 *ptype, l_int32 *pbps, l_int32 *pspp)
l_int32 pixWriteMemPnm (l_uint8 **pdata, size_t *psize, PIX *pix)

Переменные

static const l_int32 MAX_PNM_WIDTH = 100000
static const l_int32 MAX_PNM_HEIGHT = 100000

Функции

l_int32 freadHeaderPnm ( FILE *  fp,
PIX **  ppix,
l_int32 pwidth,
l_int32 pheight,
l_int32 pdepth,
l_int32 ptype,
l_int32 pbps,
l_int32 pspp 
)

freadHeaderPnm()

Input: stream opened for read &pix (<optional return>=""> use null to return only header data) &width (<return>) &height (<return>) &depth (<return>) &type (<return> pnm type) &bps (<optional return>="">, bits/sample) &spp (<optional return>="">, samples/pixel) Return: 0 if OK, 1 on error

PIX* pixReadMemPnm ( const l_uint8 cdata,
size_t  size 
)
PIX* pixReadStreamPnm ( FILE *  fp)

pixReadStreamPnm()

Input: stream opened for read Return: pix, or null on error

l_int32 pixWriteMemPnm ( l_uint8 **  pdata,
size_t *  psize,
PIX pix 
)
l_int32 pixWriteStreamAsciiPnm ( FILE *  fp,
PIX pix 
)

pixWriteStreamAsciiPnm()

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

Writes "ascii" format only: 1 bpp --> pbm (P1) 2, 4, 8, 16 bpp, no colormap or grayscale colormap --> pgm (P2) 2, 4, 8 bpp with color-valued colormap, or rgb --> rgb ppm (P3)

l_int32 pixWriteStreamPnm ( FILE *  fp,
PIX pix 
)

pixWriteStreamPnm()

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

Notes: (1) This writes "raw" packed format only: 1 bpp --> pbm (P4) 2, 4, 8, 16 bpp, no colormap or grayscale colormap --> pgm (P5) 2, 4, 8 bpp with color-valued colormap, or rgb --> rgb ppm (P6) (2) 24 bpp rgb are not supported in leptonica, but this will write them out as a packed array of bytes (3 to a pixel).

static l_int32 pnmReadNextAsciiValue ( FILE *  fp,
l_int32 pval 
) [static]

pnmReadNextAsciiValue()

Return: 0 if OK, 1 on error or EOF.

Notes: (1) This reads the next sample value in ascii from the the file.

static l_int32 pnmSkipCommentLines ( FILE *  fp) [static]

pnmSkipCommentLines()

Return: 0 if OK, 1 on error or EOF

Notes: (1) Comment lines begin with '#' (2) Usage: caller should check return value for EOF

l_int32 readHeaderPnm ( const char *  filename,
PIX **  ppix,
l_int32 pwidth,
l_int32 pheight,
l_int32 pdepth,
l_int32 ptype,
l_int32 pbps,
l_int32 pspp 
)

readHeaderPnm()

Input: filename &pix (<optional return>=""> use null to return only header data) &width (<return>) &height (<return>) &depth (<return>) &type (<return> pnm type) &bps (<optional return>="">, bits/sample) &spp (<optional return>="">, samples/pixel) Return: 0 if OK, 1 on error

l_int32 sreadHeaderPnm ( const l_uint8 cdata,
size_t  size,
l_int32 pwidth,
l_int32 pheight,
l_int32 pdepth,
l_int32 ptype,
l_int32 pbps,
l_int32 pspp 
)

Переменные

const l_int32 MAX_PNM_HEIGHT = 100000 [static]
const l_int32 MAX_PNM_WIDTH = 100000 [static]