\ .\" This man page was generated by the Netpbm tool 'makeman' from HTML source. .\" Do not hand-hack it! If you have bug fixes or improvements, please find .\" the corresponding HTML page on the Netpbm website, generate a patch .\" against that, and send it to the Netpbm maintainer. .TH "User manual for old pnm functions" 3 "8 September 2007" "netpbm documentation" .SH NAME libpnm - libnetpbm functions to read and write PNM image files .UN synopsis .SH SYNOPSIS \fB#include \fP .PP \fBvoid pnm_init(\fP \fBint *\fP\fIargcP\fP\fB,\fP \fBchar *\fP\fIargv\fP\fB[]\fP \fB);\fP .PP \fBxel ** pnm_allocarray(\fP \fBint \fP\fIcols\fP\fB,\fP \fBint \fP\fIrows\fP\fB);\fP .PP \fBxel * pnm_allocrow(\fP \fBint \fP\fIcols\fP\fB);\fP .PP \fBvoid pnm_freearray(\fP \fBxel **\fP\fIxels\fP\fB,\fP \fBint \fP\fIrows\fP\fB);\fP .PP \fBvoid pnm_freerow(\fP \fBxel *\fP\fIxelrow\fP\fB);\fP .PP \fBvoid pnm_readpnminit( \fP \fBFILE *\fP\fIfp\fP\fB,\fP \fBint *\fP\fIcolsP\fP\fB,\fP \fBint *\fP\fIrowsP\fP\fB,\fP \fBxelval *\fP\fImaxvalP\fP\fB,\fP \fBint *\fP\fIformatP\fP\fB );\fP .PP \fBvoid pnm_readpnmrow( \fP \fBFILE *\fP\fIfp\fP\fB,\fP \fBxel *\fP\fIxelrow\fP\fB,\fP \fBint \fP\fIcols\fP\fB,\fP \fBxelval \fP\fImaxval\fP\fB,\fP \fBint \fP\fIformat\fP\fB );\fP .PP \fBxel ** pnm_readpnm( \fP \fBFILE *\fP\fIfp\fP\fB,\fP \fBint *\fP\fIcolsP\fP\fB,\fP \fBint *\fP\fIrowsP\fP\fB,\fP \fBxelval *\fP\fImaxvalP\fP\fB, int\fP\fI*\fP\fB formatP \fP\fI);\fP .PP \fBvoid pnm_writepnminit( \fP \fBFILE * fp , \fP \fBint \fP\fIcols\fP\fB,\fP \fBint \fP\fIrows\fP\fB,\fP \fBxelval \fP\fImaxval\fP\fB,\fP \fBint \fP\fIformat\fP\fB,\fP \fBint \fP\fIforceplain\fP\fB);\fP .PP \fBvoid pnm_writepnmrow( \fP \fBFILE *\fP\fIfp\fP\fB,\fP \fBxel *\fP\fIxelrow\fP\fB,\fP \fBint cols\fP\fI,\fP \fBxelval \fP\fImaxval\fP\fB,\fP \fBint \fP\fIformat\fP\fB,\fP \fBint \fP\fIforceplain\fP\fB );\fP .PP \fBvoid pnm_writepnm( \fP \fBFILE *\fP\fIfp\fP\fB,\fP \fBxel ** \fP\fIxels\fP\fB,\fP \fBint \fP\fIcols\fP\fB,\fP \fBint \fP\fIrows\fP\fB,\fP \fBxelval \fP\fImaxval\fP\fB,\fP \fBint \fP\fIformat\fP\fB,\fP \fBint \fP\fIforceplain\fP\fB );\fP .PP \fBvoid pnm_nextimage(\fP\fBFILE *\fP \fIfile\fP\fB,\fP \fBint * const\fP \fIeofP\fP\fB);\fP .PP \fBvoid pnm_check(\fP \fBFILE * \fP\fIfile\fP\fB,\fP \fBconst enum pm_check_type \fP\fIcheck_type\fP\fB,\fP \fBconst int \fP\fIformat\fP\fB,\fP \fBconst int \fP\fIcols\fP\fB,\fP \fBconst int \fP\fIrows\fP\fB,\fP \fBconst xelval \fP\fImaxval\fP\fB,\fP \fBenum pm_check_code *\fP\fIretvalP\fP\fB);\fP .PP \fBvoid pnm_promoteformatrow( \fP \fBxel *\fP\fIxelrow\fP\fB,\fP \fBint \fP\fIcols\fP\fB,\fP \fBxelval \fP\fImaxval\fP\fB,\fP \fBint \fP\fIformat\fP\fB,\fP \fBxelval \fP\fInewmaxval\fP\fB,\fP \fBint \fP\fInewformat\fP\fB);\fP .PP \fBvoid pnm_promoteformat( \fP \fBxel **\fP\fIxels\fP\fB,\fP \fBint \fP\fIcols\fP\fB,\fP \fBxelval \fP\fImaxval\fP\fB,\fP \fBint \fP\fIformat\fP\fB,\fP \fBxelval \fP\fInewmaxval\fP\fB,\fP \fBint \fP\fInewformat\fP\fB);\fP .PP \fBxel pnm_whitexel( \fP \fBxelval \fP\fImaxval\fP\fB,\fP \fBint \fP\fIformat\fP\fB);\fP .PP \fBxel pnm_blackxel( \fP \fBxelval \fP\fImaxval\fP\fB,\fP \fBint \fP\fIformat\fP\fB);\fP .PP \fBvoid pnm_invertxel( \fP \fBxel *\fP\fIx\fP\fB,\fP \fBxelval \fP\fImaxval\fP\fB,\fP \fBint \fP\fIformat\fP\fB);\fP .PP \fBxel pnm_backgroundxelrow( \fP \fBxel *\fP\fIxelrow\fP\fB,\fP \fBint \fP\fIcols\fP\fB,\fP \fBxelval \fP\fImaxval\fP\fB,\fP \fBint \fP\fIformat\fP\fB);\fP .PP \fBxel pnm_backgroundxel( \fP \fBxel **\fP\fIxels\fP\fB,\fP \fBint \fP\fIcols\fP\fB,\fP \fBint \fP\fIrows\fP\fB,\fP \fBxelval \fP\fImaxval\fP\fB,\fP \fBint \fP\fIformat\fP\fB);\fP .PP \fBtypedef ... xelval;\fP .PP \fBtypedef ... xel;\fP .PP \fB#define \fP \fBPNM_ASSIGN1(\fP\fIx\fP\fB,\fP\fIv\fP\fB)\fP \fB...\fP .PP \fB#define \fP \fBPNM_GET1(\fP\fIx\fP\fB)\fP \fB...\fP .PP \fB#define \fP \fBPNM_EQUAL(\fP\fIx\fP\fB,\fP\fIy\fP\fB)\fP \fB...\fP .PP \fB#define \fP \fBPNM_FORMAT_TYPE(\fP\fIformat\fP\fB)\fP \fB...\fP .UN description .SH DESCRIPTION .PP These library functions are part of .BR Netpbm (1) . .UN types .SS TYPES AND CONSTANTS .PP Each \fBxel\fP contains three \fBxelval\fPs, each of which should contain only the values between \fB0\fP and \fBPNM_MAXMAXVAL\fP, inclusive. .UN xel .SS XEL MANIPULATIONS .PP The \fBPNM_GET1\fP macro extracts a single value from an xel, when ou know it's from a PBM or PGM file. When it's from a PPM file, use \fBPPM_GETR()\fP, \fBPPM_GETG()\fP, and \fBPPM_GETB()\fP. .PP The \fBPNM_ASSIGN1\fP 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\fP. The \fBPNM_EQUAL\fP macro checks two xels for equality. The \fBPNM_FORMAT_TYPE\fP 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\fP does not work on the PAM format code. \fBpnm_whitexel()\fP and \fBpnm_blackxel()\fP return a white or black xel, respectively, for the given \fImaxval\fP and \fIformat\fP. .PP \fBpnm_invertxel()\fP inverts an xel. .UN initialization .SS INITIALIZATION .PP \fBpnm_init()\fP is obsolete (at least since Netpbm 9.25 (March 2002)). Use .UR libpm.html#initialization \fBpm_proginit()\fP .UE \& instead. .PP \fBpnm_init()\fP is identical to \fBpm_proginit\fP. .UN memorymanagement .SS MEMORY MANAGEMENT .PP \fBpnm_allocarray()\fP allocates space for an array of xels. \fBpnm_freearray()\fP frees an array space allocated by \fBpnm_allocarray()\fP or \fBpnm_readpnm()\fP. .PP \fBpnm_allocrow()\fP allocates space for a row of a PNM image. \fBpnm_freerow()\fP frees it. .UN reading .SS READING PNM FILES .PP \fBpnm_readpnminit()\fP is similar to \fBpnm_readpaminit()\fP, but reads only PNM images and has a different parameter list. .PP \fBpnm_readpnmrow()\fP is similar to \fBpnm_readpamrow()\fP but only works on PNM images and has a different parameter list and returns the row as an array of xels instead of tuples. .PP \fBpnm_readpnm()\fP is similar to \fBpnm_readpam()\fP except that it reads only PNM images and uses a different parameter list and returns an array of rows such that \fBpnm_readpnmrow()\fP would return rather than such that \fBpnm_readpamrow()\fP would return. .UN writing .SS WRITING FILES .PP \fBpnm_writepnminit()\fP is similar to \fBpnm_writepaminit()\fP except that it can write only a PNM header and has a different parameter list. .PP \fIforceplain\fP 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 .BR PNM format specification (5) . .PP \fBpnm_writepnmrow()\fP is similar to \fBpnm_writepamrow()\fP 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 \fP above. .PP \fBpnm_writepnm()\fP is similar to \fBpnm_writepam()\fP 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\fP above. .UN promotion .SS FORMAT PROMOTION \fBpnm_promoteformatrow()\fP 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. .PP \fBpnm_promoteformat()\fP promotes an entire anymap. .UN miscellaneous .SS MISCELLANEOUS .PP \fBpnm_nextimage()\fP positions a PNM input file to the next image in it (so that a subsequent \fBpnm_readpnminit()\fP reads its header). .PP \fBpnm_nextimage()\fP is analogous to \fBpbm_nextimage()\fP, but works on PPM, PGM, and PBM files. .PP \fBpnm_check()\fP is similar to \fBpnm_checkpam()\fP except it works only on PNM images. .PP \fBpnm_check()\fP is identical to \fBppm_check()\fP. .PP \fBpnm_backgroundxelrow()\fP figures out an appropriate background xel based on the row of xels \fIxelrow\fP, which is \fIcols\fP xels wide, has maxval \fImaxval\fP, and represents an image with format \fIformat\fP. .PP This estimate works best when the row is the top or bottom row of the image. .PP \fBpnm_backgroundxel()\fP does the same thing as \fBpnm_backgroundxelrow()\fP, except based on an entire image instead of just one row. This tends to do a slightly better job than \fBpnmbackgroundxelrow()\fP. .UN seealso .SH SEE ALSO .BR Libnetpbm (3) , .BR Libnetpbm User's Guide (3) , .BR Libnetpbm Directory (1) , .BR pbm (5) , .BR pgm (5) , .BR ppm (5) , .BR pam (5) , .BR libpbm (3) , .BR libpgm (3) , .BR libppm (3) .UN author .SH AUTHOR Copyright (C) 1989, 1991 by Tony Hansen and Jef Poskanzer.