.TL User manual for old pgm functions .SH 1 pgm Functions .LP Updated: 22 July 2004 .br Table Of Contents .SH 2 NAME .LP libpgm - libnetpbm functions to read and write PGM image files .SH 2 SYNOPSIS .LP \fB#include \fR .LP \fBvoid pgm_init( \fR \fBint *\fR\fIargcP\fR\fB,\fR \fBchar *\fR\fIargv\fR\fB[]\fR \fB);\fR .LP \fBgray ** pgm_allocarray(\fR \fBint \fR\fIcols\fR\fB,\fR \fBint \fR\fIrows\fR\fB );\fR .LP \fBgray * pgm_allocrow(\fR \fBint\fR\fIcols\fR\fB );\fR .LP \fBvoid pgm_freearray(\fR \fBgray **\fR\fIgrays\fR\fB,\fR \fBint\fR\fIrows\fR\fB );\fR .LP \fBvoid pgm_freerow(\fR \fBgray *\fR\fIgrayrow\fR\fB);\fR .LP \fBvoid pgm_readpgminit( \fR \fBFILE *\fR\fIfp\fR\fB,\fR \fBint *\fR\fIcolsP\fR\fB,\fR \fBint *\fR\fIrowsP\fR\fB,\fR \fBgray *\fR\fImaxvalP\fR\fB,\fR \fBint *\fR\fIformatP\fR\fB );\fR .LP \fBvoid pgm_readpgmrow( \fR \fBFILE *\fR\fIfp\fR\fB,\fR \fBgray *\fR\fIgrayrow\fR\fB,\fR \fBint \fR\fIcols\fR\fB,\fR \fBgray \fR\fImaxval\fR\fB,\fR \fBint \fR\fIformat\fR\fB );\fR .LP \fBgray ** pgm_readpgm( \fR \fBFILE *\fR\fIfp\fR\fB,\fR \fBint *\fR\fIcolsP\fR\fB,\fR \fBint *\fR\fIrowsP\fR\fB,\fR \fBgray *\fR\fImaxvalP\fR\fB );\fR .LP \fBvoid pgm_writepgminit( \fR \fBFILE * fp , \fR \fBint \fR\fIcols\fR\fB,\fR \fBint \fR\fIrows\fR\fB,\fR \fBgray \fR\fImaxval\fR\fB,\fR \fBint \fR\fIforceplain\fR\fB );\fR .LP \fBvoid pgm_writepgmrow( \fR \fBFILE *\fR\fIfp\fR\fB,\fR \fBgray *\fR\fIgrayrow\fR\fB,\fR \fBint cols\fR\fI,\fR \fBgray \fR\fImaxval\fR\fB,\fR \fBint \fR\fIforceplain\fR\fB );\fR .LP \fBvoid pgm_writepgm( \fR \fBFILE *\fR\fIfp\fR\fB,\fR \fBgray ** \fR\fIgrays\fR\fB,\fR \fBint \fR\fIcols\fR\fB,\fR \fBint \fR\fIrows\fR\fB,\fR \fBgray \fR\fImaxval\fR\fB,\fR \fBint \fR\fIforceplain\fR\fB );\fR .LP \fBvoid pgm_writepgm( \fR \fBFILE *\fR\fIfp\fR\fB,\fR \fBgray **\fR\fIgrays\fR\fB,\fR \fBint \fR\fIcols\fR\fB,\fR \fBint \fR\fIrows\fR\fB,\fR \fBgray \fR\fImaxval\fR\fB,\fR \fBint \fR\fIforceplain\fR\fB );\fR .LP \fBvoid pgm_nextimage(\fR \fBFILE *\fR\fIfile\fR\fB,\fR \fBint * const \fR\fIeofP\fR\fB);\fR .LP \fBvoid pgm_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 int \fR\fImaxval\fR\fB,\fR \fBenum pm_check_code * const \fR\fIretval\fR\fB);\fR .LP \fBtypedef ... gray;\fR .LP \fB#define PGM_MAXMAXVAL ...\fR .LP \fB#define PGM_OVERALLMAXVAL ...\fR .LP \fBextern gray pgm_pbmmaxval;\fR .LP \fB#define PGM_FORMAT ...\fR .LP \fB#define RPGM_FORMAT ...\fR .LP \fB#define PGM_TYPE PGM_FORMAT\fR .LP \fB#define \fR \fBPGM_FORMAT_TYPE(\fR\fIformat\fR\fB)\fR \fB...\fR .SH 2 DESCRIPTION .LP .LP These library functions are part of Netpbm. .SH 3 TYPES AND CONSTANTS .LP .LP Each \fBgray\fR should contain only the values between \fB0\fR and \fBPGM_OVERALLMAXVAL\fR. \fBpgm_pbmmaxval\fR is the maxval used when a PGM program reads a PBM file. Normally it is 1; however, for some programs, a larger value gives better results. .LP \fBPGM_OVERALLMAXVAL\fR is the maximum value of a maxval in a PGM file. \fBPGM_MAXMAXVAL\fR is the maximum value of a maxval in a PGM file that is compatible with the PGM format as it existed before April 2000. It is also the maximum value of a maxval that results in the minimum possible raster size for a particular image. I.e an image with a maxval higher than \fBPGM_MAXMAXVAL\fR cannot be read or generated by old PGM processing programs and requires more file space. .LP \fBPGM_FORMAT \fR is the format code for a Plain PGM format image file. \fBRPGM_FORMAT\fR is the format code for a Raw PGM format image file. \fBPGM_TYPE \fR is the format type code for the PGM formats. \fBPGM_FORMAT_TYPE\fR is a macro that generates code to compute the format type code of a PBM or PGM format from the format code which is its argument. .SH 3 INITIALIZATION .LP .LP \fBpgm_init\fR is identical to \fBpm_init()\fR. .SH 3 MEMORY MANAGEMENT .LP \fBpgm_allocarray()\fR allocates an array of grays. .LP \fBpgm_allocrow()\fR allocates a row of the given number of grays. .LP \fBpgm_freearray()\fR frees the array allocated with \fBpgm_allocarray()\fR containing the given number of rows. .LP \fBpgm_freerow()\fR frees a row of grays allocated with \fBpgm_allocrow()\fR. .SH 3 READING FILES .LP .LP If a function in this section is called on a PBM format file, it translates the PBM file into a PGM file on the fly and functions as if it were called on the equivalent PGM file. The \fIformat\fR value returned by \fBpgm_readpgminit()\fR is, however, not translated. It represents the actual format of the PBM file. .LP \fBpgm_readpgminit()\fR reads the header of a PGM file, returning all the information from the header and leaving the file positioned just after the header. .LP \fBpgm_readpgmrow()\fR reads a row of grays into the \fIgrayrow \fR array. \fIformat\fR, \fIcols\fR, and \fImaxval \fR are the values returned by \fBpgm_readpgminit()\fR. .LP \fBpgm_readpgm()\fR reads an entire PGM image into memory, returning the allocated array as its return value and returning the information from the header as \fIrows\fR, \fIcols\fR, and \fImaxval\fR. This function combines \fBpgm_readpgminit()\fR, \fBpgm_allocarray()\fR, and \fBpgm_readpgmrow()\fR. .LP \fBpgm_readpgminit()\fR and \fBpgm_readpgm\fR abort the program with a message to Standard Error if the PGM image header is not syntactically valid, including if it contains a number too large to be processed using the system's normal data structures (to wit, a number that won't fit in a C 'int'). .SH 3 WRITING FILES .LP \fBpgm_writepgminit()\fR writes the header for a PGM file and leaves it positioned just after the header. .LP \fIforceplain\fR is a logical value that tells \fBpgm_writepgminit() \fR to write a header for a plain PGM format file, as opposed to a raw PGM format file. .LP \fBpgm_writepgmrow()\fR writes the row \fIgrayrow\fR to a PGM file. For meaningful results, \fIcols\fR, \fImaxval\fR, and \fIforceplain\fR must be the same as was used with \fBpgm_writepgminit()\fR. .LP \fBpgm_writepgm()\fR write the header and all data for a PGM image. This function combines \fBpgm_writepgminit()\fR and \fBpgm_writepgmrow()\fR. .SH 3 MISCELLANEOUS .LP .LP \fBpgm_nextimage()\fR positions a PGM input file to the next image in it (so that a subsequent \fBpgm_readpgminit()\fR reads its header). .LP \fBpgm_nextimage()\fR is analogous to \fBpbm_nextimage()\fR, but works on PGM and PBM files. .LP \fBpgm_check() \fR checks for the common file integrity error where the file is the wrong size to contain all the image data. .LP \fBpgm_check() \fR is analogous to \fBpbm_check()\fR, but works on PGM and PBM files. .SH 2 SEE ALSO .LP \fBlibpbm\fR, \fBlibppm\fR, \fBlibpnm\fR .br \l'5i' .SH 2 Table Of Contents .LP .IP \(bu NAME .IP \(bu SYNOPSIS .IP \(bu DESCRIPTION .IP \(bu TYPES AND CONSTANTS .IP \(bu INITIALIZATION .IP \(bu MEMORY MANAGEMENT .IP \(bu READING FILES .IP \(bu WRITING FILES .IP \(bu MISCELLANEOUS .LP .IP \(bu SEE ALSO .LP