.TL
User manual for old pnm functions
.SH 1
pnm Functions
.LP
Updated: 22 July 2004
.br
Table Of Contents
.SH 2
NAME
.LP
libpnm - libnetpbm functions to read and write PNM image files
.SH 2
SYNOPSIS
.LP
\fB#include <pnm.h>\fR
.LP
\fBvoid pnm_init(\fR
\fBint *\fR\fIargcP\fR\fB,\fR
\fBchar *\fR\fIargv\fR\fB[]\fR
\fB);\fR
.LP
\fBxel ** pnm_allocarray(\fR
\fBint \fR\fIcols\fR\fB,\fR
\fBint \fR\fIrows\fR\fB);\fR
.LP
\fBxel * pnm_allocrow(\fR
\fBint \fR\fIcols\fR\fB);\fR
.LP
\fBvoid pnm_freearray(\fR
\fBxel **\fR\fIxels\fR\fB,\fR
\fBint \fR\fIrows\fR\fB);\fR
.LP
\fBvoid pnm_freerow(\fR
\fBxel *\fR\fIxelrow\fR\fB);\fR
.LP
\fBvoid pnm_readpnminit( \fR
\fBFILE *\fR\fIfp\fR\fB,\fR
\fBint *\fR\fIcolsP\fR\fB,\fR
\fBint *\fR\fIrowsP\fR\fB,\fR
\fBxelval *\fR\fImaxvalP\fR\fB,\fR
\fBint *\fR\fIformatP\fR\fB );\fR
.LP
\fBvoid pnm_readpnmrow( \fR
\fBFILE *\fR\fIfp\fR\fB,\fR
\fBxel *\fR\fIxelrow\fR\fB,\fR
\fBint \fR\fIcols\fR\fB,\fR
.br
\fBxelval \fR\fImaxval\fR\fB,\fR
\fBint \fR\fIformat\fR\fB );\fR
.LP
\fBxel ** pnm_readpnm( \fR
\fBFILE *\fR\fIfp\fR\fB,\fR
\fBint *\fR\fIcolsP\fR\fB,\fR
\fBint *\fR\fIrowsP\fR\fB,\fR
.br
\fBxelval *\fR\fImaxvalP\fR\fB, int\fR\fI*\fR\fB formatP \fR\fI);\fR
.LP
\fBvoid pnm_writepnminit( \fR
\fBFILE * fp , \fR
\fBint \fR\fIcols\fR\fB,\fR
\fBint \fR\fIrows\fR\fB,\fR
\fBxelval \fR\fImaxval\fR\fB,\fR
\fBint \fR\fIformat\fR\fB,\fR
\fBint \fR\fIforceplain\fR\fB);\fR
.LP
\fBvoid pnm_writepnmrow( \fR
\fBFILE *\fR\fIfp\fR\fB,\fR
\fBxel *\fR\fIxelrow\fR\fB,\fR
\fBint cols\fR\fI,\fR
\fBxelval \fR\fImaxval\fR\fB,\fR
\fBint \fR\fIformat\fR\fB,\fR
\fBint \fR\fIforceplain\fR\fB );\fR
.LP
\fBvoid pnm_writepnm( \fR
\fBFILE *\fR\fIfp\fR\fB,\fR
\fBxel ** \fR\fIxels\fR\fB,\fR
\fBint \fR\fIcols\fR\fB,\fR
\fBint \fR\fIrows\fR\fB,\fR
\fBxelval \fR\fImaxval\fR\fB,\fR
\fBint \fR\fIformat\fR\fB,\fR
\fBint \fR\fIforceplain\fR\fB );\fR
.LP
\fBvoid pnm_check(\fR
\fBFILE * \fR\fIfile\fR\fB,\fR
\fBconst enum pm_check_type \fR\fIcheck_type\fR\fB,\fR
\fBconst int \fR\fIformat\fR\fB,\fR
\fBconst int \fR\fIcols\fR\fB,\fR
\fBconst int \fR\fIrows\fR\fB,\fR
\fBconst xelval \fR\fImaxval\fR\fB,\fR
\fBenum pm_check_code *\fR\fIretvalP\fR\fB);\fR
.LP
\fBvoid pnm_promoteformatrow( \fR
\fBxel *\fR\fIxelrow\fR\fB,\fR
\fBint \fR\fIcols\fR\fB,\fR
\fBxelval \fR\fImaxval\fR\fB,\fR
\fBint \fR\fIformat\fR\fB,\fR
\fBxelval \fR\fInewmaxval\fR\fB,\fR
\fBint \fR\fInewformat\fR\fB);\fR
.LP
\fBvoid pnm_promoteformat( \fR
\fBxel **\fR\fIxels\fR\fB,\fR
\fBint \fR\fIcols\fR\fB,\fR
\fBxelval \fR\fImaxval\fR\fB,\fR
\fBint \fR\fIformat\fR\fB,\fR
\fBxelval \fR\fInewmaxval\fR\fB,\fR
\fBint \fR\fInewformat\fR\fB);\fR
.LP
\fBxel pnm_whitexel( \fR
\fBxelval \fR\fImaxval\fR\fB,\fR
\fBint \fR\fIformat\fR\fB);\fR
.LP
\fBxel pnm_blackxel( \fR
\fBxelval \fR\fImaxval\fR\fB,\fR
\fBint \fR\fIformat\fR\fB);\fR
.LP
\fBvoid pnm_invertxel( \fR
\fBxel *\fR\fIx\fR\fB,\fR
\fBxelval \fR\fImaxval\fR\fB,\fR
\fBint \fR\fIformat\fR\fB);\fR
.LP
\fBxel pnm_backgroundxelrow( \fR
\fBxel *\fR\fIxelrow\fR\fB,\fR
\fBint \fR\fIcols\fR\fB,\fR
\fBxelval \fR\fImaxval\fR\fB,\fR
\fBint \fR\fIformat\fR\fB);\fR
.LP
\fBxel pnm_backgroundxel( \fR
\fBxel **\fR\fIxels\fR\fB,\fR
\fBint \fR\fIcols\fR\fB,\fR
\fBint \fR\fIrows\fR\fB,\fR
\fBxelval \fR\fImaxval\fR\fB,\fR
\fBint \fR\fIformat\fR\fB);\fR
.LP
\fBtypedef ... xelval;\fR
.LP
\fBtypedef ... xel;\fR
.LP
\fBextern xelval pnm_pbmmaxval;\fR
.LP
\fB#define \fR
\fBPNM_ASSIGN1(\fR\fIx\fR\fB,\fR\fIv\fR\fB)\fR
\fB...\fR
.LP
\fB#define \fR
\fBPNM_GET1(\fR\fIx\fR\fB)\fR
\fB...\fR
.LP
\fB#define \fR
\fBPNM_EQUAL(\fR\fIx\fR\fB,\fR\fIy\fR\fB)\fR
\fB...\fR
.LP
\fB#define \fR
\fBPNM_FORMAT_TYPE(\fR\fIformat\fR\fB)\fR
\fB...\fR
.SH 2
DESCRIPTION
.LP
.LP
These library functions are part of Netpbm.
.SH 3
PNM TYPES AND CONSTANTS
.LP
.LP
Each \fBxel\fR contains three \fBxelval\fRs, each of which should
contain only the values between \fB0\fR and \fBPNM_MAXMAXVAL\fR,
inclusive. \fBpnm_pbmmaxval\fR is the maxval used when a PNM program
reads a PBM file. Normally it is 1; however, for some programs, a
larger value gives better results.
.SH 3
PNM XEL MANIPULATIONS
.LP
.LP
The \fBPNM_GET1\fR macro extracts a single value from an xel, when
you know it's from a PBM or PGM file. When it's from a PPM file, use
\fBPPM_GETR()\fR, \fBPPM_GETG()\fR, and \fBPPM_GETB()\fR.
.LP
The \fBPNM_ASSIGN1\fR macro assigns a single value to an xel, when
you know it's from a PBM or PGM file. When it's from a PPM file, use
\fBPPM_ASSIGN\fR.
The \fBPNM_EQUAL\fR macro checks two xels for equality. The
\fBPNM_FORMAT_TYPE\fR macro computes a
format type code from a format code. The format types are PBM, PGM,
PPM, and PAM. But note that PBM, PGM, and PPM each are two different
formats: a plain one and a raw one. So there are four format types,
but seven formats. \fBPNM_FORMAT_TYPE\fR does not work on the PAM
format code.
.SH 3
INITIALIZATION
.LP
.LP
\fBpnm_init\fR is identical to \fBpm_init()\fR.
.SH 3
MEMORY MANAGEMENT
.LP
.LP
\fBpnm_allocarray()\fR allocates space for an array of xels.
\fBpnm_freearray()\fR frees an array space allocated by
\fBpnm_allocarray()\fR or \fBpnm_readpnm()\fR.
.LP
\fBpnm_allocrow()\fR allocates space for a row of a PNM image.
\fBpnm_freerow()\fR frees it.
.SH 3
READING PNM FILES
.LP
.LP
\fBpnm_readpnminit()\fR is similar to \fBpnm_readpaminit()\fR,
but reads only PNM images and has a different parameter list.
.LP
\fBpnm_readpnmrow()\fR is similar to \fBpnm_readpamrow()\fR
but only works on PNM images and has a different parameter list and returns
the row as an array of xels instead of tuples.
.LP
\fBpnm_readpnm()\fR is similar to \fBpnm_readpam()\fR except that
it reads only PNM images and uses a different parameter list and
returns an array of rows such that \fBpnm_readpnmrow()\fR would
return rather than such that \fBpnm_readpamrow()\fR would return.
.SH 3
WRITING FILES
.LP
.LP
\fBpnm_writepnminit()\fR is similar to \fBpnm_writepaminit()\fR
except that it can write only a PNM header and has a different
parameter list.
.LP
\fIforceplain\fR is a binary value. True (nonzero) means to write
the image in the plain (ASCII) version of the selected format. False
(zero) means to write it in the raw (binary) version of the selected
format. See PNM format specification.
.LP
\fBpnm_writepnmrow()\fR is similar to \fBpnm_writepamrow()\fR
except that it works only on PNM images and has a different parameter
list and takes an array of xels instead of an array of tuples. See
the description of \fIforceplain \fR above.
.LP
\fBpnm_writepnm()\fR is similar to \fBpnm_writepam()\fR except
that it works only on PNM image, has a different parameter list, and
takes an array of rows of xels instead of an array of rows of tuples.
See the description of \fIforceplain\fR above.
.SH 3
MISCELLANEOUS
.LP
.LP
\fBpnm_check()\fR is similar to \fBpnm_checkpam()\fR except it
works only on PNM images.
.LP
\fBpnm_check()\fR is identical to \fBppm_check()\fR.
.SH 3
PNM FORMAT PROMOTION
.LP
\fBpnm_promoteformatrow()\fR promotes a row of xels from one maxval
and format to a new set. Use this when you are combining multiple
anymaps of different types - just take the maximum of the maxvals and
the maximum of the formats, and promote them all to that.
.LP
\fBpnm_promoteformat()\fR promotes an entire anymap.
.SH 3
PNM XEL MANIPULATION
.LP
\fBpnm_whitexel()\fR and \fBpnm_blackxel()\fR return a white or
black xel, respectively, for the given \fImaxval\fR and
\fIformat\fR.
.LP
\fBpnm_invertxel()\fR inverts an xel.
.LP
\fBpnm_backgroundxelrow()\fR figures out an appropriate background
xel based on the row of xels \fIxelrow\fR, which is \fIcols\fR xels
wide, has maxval \fImaxval\fR, and represents an image with format
\fIformat\fR.
.LP
This estimate works best when the row is the top or bottom row of
the image.
.LP
\fBpnm_backgroundxel()\fR does the same thing as
\fBpnm_backgroundxelrow()\fR, except based on an entire image instead
of just one row. This tends to do a slightly better job than
\fBpnmbackgroundxelrow()\fR.
.SH 2
SEE ALSO
.LP
\fBLibnetpbm\fR,
\fBLibnetpbm User's Guide\fR,
\fBLibnetpbm Directory\fR,
\fBpbm\fR,
\fBpgm\fR,
\fBppm\fR,
\fBpam\fR,
\fBlibpbm\fR,
\fBlibpgm\fR,
\fBlibppm\fR
.SH 2
AUTHOR
.LP
Copyright (C) 1989, 1991 by Tony Hansen and Jef Poskanzer.
.br
\l'5i'
.SH 2
Table Of Contents
.LP
.IP \(bu
NAME
.IP \(bu
SYNOPSIS
.IP \(bu
DESCRIPTION
.IP \(bu
PNM TYPES AND CONSTANTS
.IP \(bu
PNM XEL MANIPULATIONS
.IP \(bu
The
.IP \(bu
INITIALIZATION
.IP \(bu
MEMORY MANAGEMENT
.IP \(bu
READING PNM FILES
.IP \(bu
WRITING FILES
.IP \(bu
MISCELLANEOUS
.IP \(bu
PNM FORMAT PROMOTION
.IP \(bu
PNM XEL MANIPULATION
.LP
.IP \(bu
SEE ALSO
.IP \(bu
AUTHOR
.LP
|