.de Ss . sp . ft CW . nf .. .de Se . fi . ft P . sp .. .TH pgm 3 .SH NAME pgm - functions to support portable graymap programs .SH SYNOPSIS .Ss #include cc ... libpgm.a libpbm.a .Se .SH DESCRIPTION .SS TYPES AND CONSTANTS .Ss typedef unsigned char gray; #define PGM_MAXMAXVAL 255 extern gray pgm_pbmmaxval; .Se Each .IR gray should contain only the values between .IR 0 and .IR PGM_MAXMAXVAL . .IR 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 PGM 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( grayrow, rows ) .Se Free the array allocated with .IR pgm_allocarray() containing the given number of rows. .Ss pbm_freerow( grayrow ) .Se Free a row of grays. .SS READING PBM FILES .Ss void pgm_readpgminit( file, colsP, rowsP, maxvalP, formatP ) FILE *file; int *colsP, *rowsP, *formatP; gray *maxvalP; .Se Read the header from a pgm file, filling in the rows, cols, maxval and format variables. .Ss void pgm_readpgmrow( file, grayrow, cols, maxval, format ) FILE *file; gray *grayrow; gray maxval; int cols, format; .Se Read a row of grays into the grayrow array. Format and cols were filled in by .IR pgm_readpgminit() . .Ss gray ** pgm_readpgm( file, colsP, rowsP, maxvalP ) FILE *file; int *colsP, *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 .IR pgm_readpgminit() , .IR pgm_allocarray() and .IR pgm_readpgmrow() . .SS WRITING PGM FILES .Ss void pgm_writepgminit( file, cols, rows, maxval ) FILE *file; int cols, rows; gray maxval; .Se Write the header for a portable graymap file. .Ss void pgm_writepgmrow( file, grayrow, cols, maxval ) FILE *file; gray *grayrow; int cols; gray maxval; .Se Write a row from a portable graymap. .Ss void pgm_writepgm( file, bits, cols, rows, maxval ) FILE *file; gray **bits; int cols, rows; gray maxval; .Se Write the header and all data for a portable graymap. This function combines .IR pgm_writepgminit() and .IR pgm_writepgmrow() . .SH "SEE ALSO" pgm(3), ppm(3) .SH AUTHOR Manual by Tony Hansen. Copyright (C) 1989 by 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.