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

Функции

static l_int32 pnmReadNextAsciiValue (FILE *fp, l_int32 *pval)
 
static l_int32 pnmReadNextNumber (FILE *fp, l_int32 *pval)
 
static l_int32 pnmSkipCommentLines (FILE *fp)
 
PIXpixReadStreamPnm (FILE *fp)
 
l_int32 readHeaderPnm (const char *filename, l_int32 *pw, l_int32 *ph, l_int32 *pd, l_int32 *ptype, l_int32 *pbps, l_int32 *pspp)
 
l_int32 freadHeaderPnm (FILE *fp, l_int32 *pw, l_int32 *ph, l_int32 *pd, l_int32 *ptype, l_int32 *pbps, l_int32 *pspp)
 
l_int32 pixWriteStreamPnm (FILE *fp, PIX *pix)
 
l_int32 pixWriteStreamAsciiPnm (FILE *fp, PIX *pix)
 
FILE * open_memstream (char **data, size_t *size)
 
FILE * fmemopen (void *data, size_t size, const char *mode)
 
PIXpixReadMemPnm (const l_uint8 *cdata, size_t size)
 
l_int32 readHeaderMemPnm (const l_uint8 *cdata, size_t size, l_int32 *pw, l_int32 *ph, l_int32 *pd, 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
 

Функции

◆ fmemopen()

FILE* fmemopen ( void *  data,
size_t  size,
const char *  mode 
)

◆ freadHeaderPnm()

l_int32 freadHeaderPnm ( FILE *  fp,
l_int32 pw,
l_int32 ph,
l_int32 pd,
l_int32 ptype,
l_int32 pbps,
l_int32 pspp 
)

freadHeaderPnm()

Input:  stream opened for read
        &w (<optional return>)
        &h (<optional return>)
        &d (<optional return>)
        &type (<optional return> pnm type)
        &bps (<optional return>, bits/sample)
        &spp (<optional return>, samples/pixel)
Return: 0 if OK, 1 on error

◆ open_memstream()

FILE* open_memstream ( char **  data,
size_t *  size 
)

◆ pixReadMemPnm()

PIX* pixReadMemPnm ( const l_uint8 cdata,
size_t  size 
)

pixReadMemPnm()

Input:  cdata (const; pnm-encoded)
        size (of data)
Return: pix, or null on error

Notes: (1) The @size byte of @data must be a null character.

◆ pixReadStreamPnm()

PIX* pixReadStreamPnm ( FILE *  fp)

pixReadStreamPnm()

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

◆ pixWriteMemPnm()

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

pixWriteMemPnm()

Input:  &data (<return> data of tiff compressed image)
        &size (<return> size of returned data)
        pix
Return: 0 if OK, 1 on error

Notes: (1) See pixWriteStreamPnm() for usage. This version writes to memory instead of to a file stream.

◆ pixWriteStreamAsciiPnm()

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)

◆ pixWriteStreamPnm()

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).

◆ pnmReadNextAsciiValue()

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.

◆ pnmReadNextNumber()

static l_int32 pnmReadNextNumber ( FILE *  fp,
l_int32 pval 
)
static

pnmReadNextNumber()

Input:  file stream
        &val (<return> value as an integer)
Return: 0 if OK, 1 on error or EOF.

Notes: (1) This reads the next set of numeric chars, returning the value and swallowing the trailing whitespace character. This is needed to read the maxval in the header, which precedes the binary data.

◆ pnmSkipCommentLines()

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

◆ readHeaderMemPnm()

l_int32 readHeaderMemPnm ( const l_uint8 cdata,
size_t  size,
l_int32 pw,
l_int32 ph,
l_int32 pd,
l_int32 ptype,
l_int32 pbps,
l_int32 pspp 
)

readHeaderMemPnm()

Input:  cdata (const; pnm-encoded)
        size (of data)
        &w (<optional return>)
        &h (<optional return>)
        &d (<optional return>)
        &type (<optional return> pnm type)
        &bps (<optional return>, bits/sample)
        &spp (<optional return>, samples/pixel)
Return: 0 if OK, 1 on error

◆ readHeaderPnm()

l_int32 readHeaderPnm ( const char *  filename,
l_int32 pw,
l_int32 ph,
l_int32 pd,
l_int32 ptype,
l_int32 pbps,
l_int32 pspp 
)

readHeaderPnm()

Input:  filename
        &w (<optional return>)
        &h (<optional return>)
        &d (<optional return>)
        &type (<optional return> pnm type)
        &bps (<optional return>, bits/sample)
        &spp (<optional return>, samples/pixel)
Return: 0 if OK, 1 on error

Переменные

◆ MAX_PNM_HEIGHT

const l_int32 MAX_PNM_HEIGHT = 100000
static

◆ MAX_PNM_WIDTH

const l_int32 MAX_PNM_WIDTH = 100000
static