\ .\" 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 pgm functions" 3 "8 September 2007" "netpbm documentation" .SH NAME libpgm - libnetpbm functions to read and write PGM image files .UN synopsis .SH SYNOPSIS \fB#include \fP .PP \fBvoid pgm_init( \fP \fBint *\fP\fIargcP\fP\fB,\fP \fBchar *\fP\fIargv\fP\fB[]\fP \fB);\fP .PP \fBgray ** pgm_allocarray(\fP \fBint \fP\fIcols\fP\fB,\fP \fBint \fP\fIrows\fP\fB );\fP .PP \fBgray * pgm_allocrow(\fP \fBint\fP\fIcols\fP\fB );\fP .PP \fBvoid pgm_freearray(\fP \fBgray **\fP\fIgrays\fP\fB,\fP \fBint\fP\fIrows\fP\fB );\fP .PP \fBvoid pgm_freerow(\fP \fBgray *\fP\fIgrayrow\fP\fB);\fP .PP \fBvoid pgm_readpgminit( \fP \fBFILE *\fP\fIfp\fP\fB,\fP \fBint *\fP\fIcolsP\fP\fB,\fP \fBint *\fP\fIrowsP\fP\fB,\fP \fBgray *\fP\fImaxvalP\fP\fB,\fP \fBint *\fP\fIformatP\fP\fB );\fP .PP \fBvoid pgm_readpgmrow( \fP \fBFILE *\fP\fIfp\fP\fB,\fP \fBgray *\fP\fIgrayrow\fP\fB,\fP \fBint \fP\fIcols\fP\fB,\fP \fBgray \fP\fImaxval\fP\fB,\fP \fBint \fP\fIformat\fP\fB );\fP .PP \fBgray ** pgm_readpgm( \fP \fBFILE *\fP\fIfp\fP\fB,\fP \fBint *\fP\fIcolsP\fP\fB,\fP \fBint *\fP\fIrowsP\fP\fB,\fP \fBgray *\fP\fImaxvalP\fP\fB );\fP .PP \fBvoid pgm_writepgminit( \fP \fBFILE * fp , \fP \fBint \fP\fIcols\fP\fB,\fP \fBint \fP\fIrows\fP\fB,\fP \fBgray \fP\fImaxval\fP\fB,\fP \fBint \fP\fIforceplain\fP\fB );\fP .PP \fBvoid pgm_writepgmrow( \fP \fBFILE *\fP\fIfp\fP\fB,\fP \fBgray *\fP\fIgrayrow\fP\fB,\fP \fBint cols\fP\fI,\fP \fBgray \fP\fImaxval\fP\fB,\fP \fBint \fP\fIforceplain\fP\fB );\fP .PP \fBvoid pgm_writepgm( \fP \fBFILE *\fP\fIfp\fP\fB,\fP \fBgray ** \fP\fIgrays\fP\fB,\fP \fBint \fP\fIcols\fP\fB,\fP \fBint \fP\fIrows\fP\fB,\fP \fBgray \fP\fImaxval\fP\fB,\fP \fBint \fP\fIforceplain\fP\fB );\fP .PP \fBvoid pgm_writepgm( \fP \fBFILE *\fP\fIfp\fP\fB,\fP \fBgray **\fP\fIgrays\fP\fB,\fP \fBint \fP\fIcols\fP\fB,\fP \fBint \fP\fIrows\fP\fB,\fP \fBgray \fP\fImaxval\fP\fB,\fP \fBint \fP\fIforceplain\fP\fB );\fP .PP \fBvoid pgm_nextimage(\fP \fBFILE *\fP\fIfile\fP\fB,\fP \fBint * const \fP\fIeofP\fP\fB);\fP .PP \fBvoid pgm_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 int \fP\fImaxval\fP\fB,\fP \fBenum pm_check_code * const \fP\fIretval\fP\fB);\fP .PP \fBtypedef ... gray;\fP .PP \fB#define PGM_MAXMAXVAL ...\fP .PP \fB#define PGM_OVERALLMAXVAL ...\fP .PP \fB#define PGM_FORMAT ...\fP .PP \fB#define RPGM_FORMAT ...\fP .PP \fB#define PGM_TYPE PGM_FORMAT\fP .PP \fB#define \fP \fBPGM_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 \fBgray\fP should contain only the values between \fB0\fP and \fBPGM_OVERALLMAXVAL\fP. .PP \fBPGM_OVERALLMAXVAL\fP is the maximum value of a maxval in a PGM file. \fBPGM_MAXMAXVAL\fP 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\fP cannot be read or generated by old PGM processing programs and requires more file space. .PP \fBPGM_FORMAT \fP is the format code for a Plain PGM format image file. \fBRPGM_FORMAT\fP is the format code for a Raw PGM format image file. \fBPGM_TYPE \fP is the format type code for the PGM formats. \fBPGM_FORMAT_TYPE\fP 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. .UN initialization .SS INITIALIZATION .PP \fBpgm_init()\fP is obsolete (at least since Netpbm 9.25 (March 2002)). Use .UR libpm.html#initialization \fBpm_proginit()\fP .UE \& instead. .PP \fBpgm_init()\fP is identical to \fBpm_proginit\fP. .UN memorymanagement .SS MEMORY MANAGEMENT \fBpgm_allocarray()\fP allocates an array of grays. .PP \fBpgm_allocrow()\fP allocates a row of the given number of grays. .PP \fBpgm_freearray()\fP frees the array allocated with \fBpgm_allocarray()\fP containing the given number of rows. .PP \fBpgm_freerow()\fP frees a row of grays allocated with \fBpgm_allocrow()\fP. .UN reading .SS READING FILES .PP 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\fP value returned by \fBpgm_readpgminit()\fP is, however, not translated. It represents the actual format of the PBM file. .PP \fBpgm_readpgminit()\fP reads the header of a PGM file, returning all the information from the header and leaving the file positioned just after the header. .PP \fBpgm_readpgmrow()\fP reads a row of grays into the \fIgrayrow \fP array. \fIformat\fP, \fIcols\fP, and \fImaxval \fP are the values returned by \fBpgm_readpgminit()\fP. .PP \fBpgm_readpgm()\fP reads an entire PGM image into memory, returning the allocated array as its return value and returning the information from the header as \fIrows\fP, \fIcols\fP, and \fImaxval\fP. This function combines \fBpgm_readpgminit()\fP, \fBpgm_allocarray()\fP, and \fBpgm_readpgmrow()\fP. .PP \fBpgm_readpgminit()\fP and \fBpgm_readpgm\fP 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'). .UN writing .SS WRITING FILES \fBpgm_writepgminit()\fP writes the header for a PGM file and leaves it positioned just after the header. .PP \fIforceplain\fP is a logical value that tells \fBpgm_writepgminit() \fP to write a header for a plain PGM format file, as opposed to a raw PGM format file. .PP \fBpgm_writepgmrow()\fP writes the row \fIgrayrow\fP to a PGM file. For meaningful results, \fIcols\fP, \fImaxval\fP, and \fIforceplain\fP must be the same as was used with \fBpgm_writepgminit()\fP. .PP \fBpgm_writepgm()\fP write the header and all data for a PGM image. This function combines \fBpgm_writepgminit()\fP and \fBpgm_writepgmrow()\fP. .UN miscellaneous .SS MISCELLANEOUS .PP \fBpgm_nextimage()\fP positions a PGM input file to the next image in it (so that a subsequent \fBpgm_readpgminit()\fP reads its header). .PP \fBpgm_nextimage()\fP is analogous to \fBpbm_nextimage()\fP, but works on PGM and PBM files. .PP \fBpgm_check() \fP checks for the common file integrity error where the file is the wrong size to contain all the image data. .PP \fBpgm_check() \fP is analogous to \fBpbm_check()\fP, but works on PGM and PBM files. .UN seealso .SH SEE ALSO .BR libpbm (3) , .BR libppm (3) , .BR libpnm (3)