bit **pbm_allocarray(int cols, int rows);
bit *pbm_allocrow(int cols);
pbm_freearray(bit **bits, int rows);
pbm_freerow(bit *bitrow);
void pbm_readpbminit(FILE * fp, int *colsP, int *rowsP, int *formatP);
void pbm_readpbmrow(FILE * fp, bit *bitrow, int cols, int format);
void pbm_readpbmrow_packed(FILE *
fp,
unsigned char * const packed_bits,
const int cols,
const int format);
void bit** pbm_readpbm(FILE * fp, int *colsP, int *rowsP);
void pbm_writepbminit(FILE * fp, int cols, int rows, int forceplain);
void pbm_writepbmrow(FILE * fp, bit *bitrow, int cols, int forceplain);
void pbm_writepbmrow_packed(FILE *
fp,
unsigned char * const packed_bits,
const int cols,
const int forceplain);
void pbm_writepbm(FILE * fp, bit **bits, int cols, int rows, int forceplain);
#define pbm_packed_bytes(cols) ...
void pbm_nextimage( FILE *file, int * const eofP);
void pbm_check( FILE * file, const enum pm_check_type check_type, const int format, const int cols, const int rows, enum pm_check_code * const retval);
#define PBM_WHITE ...
#define PBM_BLACK ...
Each bit should contain only the values of PBM_WHITE or PBM_BLACK.
#define PBM_FORMAT ...
#define RPBM_FORMAT ...
#define PBM_TYPE PBM_FORMAT
#define PBM_FORMAT_TYPE(f) ...
These are for distinguishing different file formats and types.
pbm_readpbm() reads an entire bitmap file into memory, returning the allocated array and filling in the rows and cols variables. This function combines pbm_readpbminit(), pbm_allocarray() and pbm_readpbmrow().
pbm_writepbm() writes the header and all data for a PBM image to a PBM file. This function combines pbm_writepbminit() and pbm_writepbmrow().
pbm_nextimage() positions a PBM input file to the next image in it (so that a subsequent pbm_readpbminit() reads its header).
Immediately before a call to pbm_nextimage(), the file must be positioned either at its beginning (i.e. nothing has been read from the file yet) or just after an image (i.e. as left by a pbm_readpbmrow() of the last row in the image).
In effect, then, all pbm_nextimage() does is test whether there is a next image or the file is positioned at end-of-file.
If pbm_nextimage() successfully positions to the next image, it returns *eofP false (0). If there is no next image in the file, it returns *eofP true . If it can't position or determine the file status due to a file error, it issues an error message and exits the program with an error exit code.
pbm_check() checks for the common file integrity error where the file is the wrong size to contain all the image data. pbm_check() assumes the file is positioned after an image header (as if pbm_readpbminit() was the last operation on the file). It checks the file size to see if the number of bytes left in the file are the number required to contain the image raster. If the file is too short, pbm_check() causes the program to exit with an error message and error completion code. Otherwise, it returns one of the following values (enumerations of the enum pm_check_code type) as *retval:
check_type must have the value PM_CHECK_BASIC (an enumerated value of the pm_check_type enumerated type). Otherwise, the effect of pbm_check() is unpredictable. This argument exists for future backward compatible expansion of the function of pbm_check().