.TH libpgm 3 .SH NAME libpgm - functions to support portable graymap programs .SH SYNOPSIS .de Ss .sp .ft CW .nf .. .de Se .fi .ft P .sp .. .Ss #include cc ... libpgm.a libpbm.a .Se .SH DESCRIPTION .SS TYPES AND CONSTANTS .Ss typedef ... gray; #define PGM_MAXMAXVAL ... extern gray pgm_pbmmaxval; .Se Each .BR gray should contain only the values between .BR 0 and .BR PGM_MAXMAXVAL . .BR pgm_pbmmaxval 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. .Ss #define PGM_FORMAT ... #define RPGM_FORMAT ... #define PGM_TYPE PGM_FORMAT int PGM_FORMAT_TYPE( int format ) .Se For distinguishing different file formats and types. .SS INITIALIZATION .Ss void pgm_init( int* argcP, char* argv[] ) .Se All PGM programs must call this routine. .SS MEMORY MANAGEMENT .Ss gray** pgm_allocarray( int cols, int rows ) .Se Allocate an array of grays. .Ss gray* pgm_allocrow( int cols ) .Se Allocate a row of the given number of grays. .Ss void pgm_freearray( gray** grays, int rows ) .Se Free the array allocated with .BR pgm_allocarray() containing the given number of rows. .Ss void pgm_freerow( gray* grayrow ) .Se Free a row of grays. .SS READING FILES .Ss void pgm_readpgminit( FILE* fp, int* colsP, int* rowsP, gray* maxvalP, int* formatP ) .Se Read the header from a PGM file, filling in the rows, cols, maxval and format variables. .Ss void pgm_readpgmrow( FILE* fp, gray* grayrow, int cols, gray maxval, int format ) .Se Read a row of grays into the grayrow array. Format, cols, and maxval were filled in by .BR pgm_readpgminit() . .Ss gray** pgm_readpgm( FILE* fp, int* colsP, int* rowsP, gray* maxvalP ) .Se Read an entire graymap file into memory, returning the allocated array and filling in the rows, cols and maxval variables. This function combines .BR pgm_readpgminit() , .BR pgm_allocarray() and .BR pgm_readpgmrow() . .SS WRITING FILES .Ss void pgm_writepgminit( FILE* fp, int cols, int rows, gray maxval, int forceplain ) .Se Write the header for a portable graymap file. The forceplain flag forces a plain-format file to be written, as opposed to a raw-format one. .Ss void pgm_writepgmrow( FILE* fp, gray* grayrow, int cols, gray maxval, int forceplain ) .Se Write a row from a portable graymap. .Ss void pgm_writepgm( FILE* fp, gray** grays, int cols, int rows, gray maxval, int forceplain ) .Se Write the header and all data for a portable graymap. This function combines .BR pgm_writepgminit() and .BR pgm_writepgmrow() . .SH "SEE ALSO" libpbm(3), libppm(3), libpnm(3) .SH AUTHOR Copyright (C) 1989, 1991 by Tony Hansen and Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty.