\ .\" 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 pbm functions" 3 "08 September 2007" "netpbm documentation" .SH NAME libpbm - libnetpbm functions to read and write PBM image files .UN synopsis .SH SYNOPSIS \fB#include \fP .PP \fBbit **pbm_allocarray(int\fP \fIcols\fP\fB, int \fP\fIrows\fP\fB);\fP .PP \fBbit *pbm_allocrow(int\fP \fIcols\fP\fB);\fP .PP \fBpbm_freearray(bit \fP \fB**\fP\fIbits\fP\fB, int \fP\fIrows\fP\fB);\fP .PP \fBpbm_freerow(bit\fP \fB*\fP\fIbitrow\fP\fB);\fP .PP \fBvoid pbm_readpbminit(FILE *\fP \fIfp\fP\fB, int *\fP\fIcolsP\fP\fB, int *\fP\fIrowsP\fP\fB, int *\fP\fIformatP\fP\fB);\fP .PP \fBvoid pbm_readpbmrow(FILE *\fP \fIfp\fP\fB, bit *\fP\fIbitrow\fP\fB, int \fP\fIcols\fP\fB, int \fP\fIformat\fP\fB);\fP .PP \fBvoid pbm_readpbmrow_packed(FILE *\fP \fIfp\fP\fB,\fP \fBunsigned char * const \fP\fIpacked_bits\fP\fB,\fP \fBconst int \fP\fIcols\fP\fB,\fP \fBconst int \fP\fIformat\fP\fB);\fP .PP \fBvoid bit** pbm_readpbm(FILE *\fP \fIfp\fP\fB, int *\fP\fIcolsP\fP\fB, int *\fP\fIrowsP\fP\fB);\fP .PP \fBvoid pbm_writepbminit(FILE *\fP \fIfp\fP\fB, int \fP\fIcols\fP\fB, int \fP\fIrows\fP\fB, int \fP\fIforceplain\fP\fB);\fP .PP \fBvoid pbm_writepbmrow(FILE *\fP \fIfp\fP\fB, bit *\fP\fIbitrow\fP\fB, int \fP\fIcols\fP\fB, int \fP\fIforceplain\fP\fB);\fP .PP \fBvoid pbm_writepbmrow_packed(FILE *\fP \fIfp\fP\fB,\fP \fBunsigned char * const \fP\fIpacked_bits\fP\fB,\fP \fBconst int \fP\fIcols\fP\fB,\fP \fBconst int \fP\fIforceplain\fP\fB);\fP .PP \fBvoid pbm_writepbm(FILE *\fP \fIfp\fP\fB, bit **\fP\fIbits\fP\fB, int \fP\fIcols\fP\fB, int \fP\fIrows\fP\fB, int \fP\fIforceplain\fP\fB);\fP .PP \fB#define pbm_packed_bytes(\fP\fIcols\fP\fB) ...\fP .PP \fBvoid pbm_nextimage(\fP \fBFILE *\fP\fIfile\fP\fB,\fP \fBint * const \fP\fIeofP\fP\fB);\fP .PP \fBvoid pbm_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 \fBenum pm_check_code * const \fP\fIretval\fP\fB);\fP .UN description .SH DESCRIPTION .PP These library functions are part of .BR "Netpbm" (1)\c \&. .UN types .SS TYPES AND CONSTANTS \fBtypedef ... bit;\fP .PP \fB#define PBM_WHITE ...\fP .PP \fB#define PBM_BLACK ...\fP .PP Each \fBbit\fP should contain only the values of \fBPBM_WHITE\fP or \fBPBM_BLACK\fP. .PP \fB#define PBM_FORMAT ...\fP .PP \fB#define RPBM_FORMAT ...\fP .PP \fB#define PBM_TYPE PBM_FORMAT\fP .PP \fB#define \fP \fBPBM_FORMAT_TYPE(\fP\fIf\fP\fB) ...\fP .PP These are for distinguishing different file formats and types. .UN initialization .SS INITIALIZATION .PP \fBpbm_init()\fP is obsolete (at least since Netpbm 9.25 (March 2002)). Use .UR libpm.html#initialization \fBpm_proginit()\fP .UE \& instead. .PP \fBpbm_init()\fP is identical to \fBpm_proginit\fP. .UN memorymanagement .SS MEMORY MANAGEMENT \fBpbm_allocarray()\fP allocates an array of bits. \fBpbm_allocrow()\fP allocates a row of the given number of bits. \fBpbm_freearray()\fP frees the array allocated with \fBpbm_allocarray()\fP containing the given number of rows. \fBpbm_freerow()\fP frees a row of bits. .UN reading .SS READING PBM IMAGE FILES .PP \fBpbm_readpbminit()\fP reads the header from a PBM image in a PBM file, filling in the rows, cols and format variables. \fBpbm_readpbmrow()\fP reads a row of bits into the \fIbitrow \fP array. Format and cols were filled in by \fBpbm_readpbminit()\fP. \fBpbm_readpbmrow_packed()\fP is like \fBpbm_readpbmrow()\fP except instead of returning a \fBbits\fP array, it returns an array \fIpacked_bits\fP of bytes with the pixels of the image row packed into them. The pixels are in order from left to right across the row and from the beginning of the array to the end. Within a byte, the bits are in order from the most significant bit to the least significant bit. If the number of pixels in the row is not a multiple of 8, the last byte returned is padded on the least significant bit side with undefined bits. White is represented by a \fBPBM_WHITE\fP bit; black by \fBPBM_BLACK\fP. .PP \fBpbm_readpbm()\fP reads an entire bitmap file into memory, returning the allocated array and filling in the rows and cols variables. This function combines \fBpbm_readpbminit()\fP, \fBpbm_allocarray()\fP and \fBpbm_readpbmrow()\fP. .PP \fBpbm_readpbminit()\fP and \fBpbm_readpbm\fP abort the program with a message to Standard Error if the PBM 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'). .PP \fBppm_readppminit()\fP and \fBppm_readppm\fP abort the program with a message to Standard Error if the PPM 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 PBM IMAGE FILES \fBpbm_writepbminit()\fP writes the header for a PBM image in a PBM file. \fIforceplain\fP is a boolean value specifying that a plain format (text) file to be written, as opposed to a raw format (binary) one. \fBpbm_writepbmrow()\fP writes a row to a PBM file. \fBpbm_writepbmrow_packed()\fP is the same as \fBpbm_writepbmrow()\fP except that you supply the row to write as an array of bytes packed with bits instead of as a \fBbits\fP array. The format of \fIpacked_bits \fP is the same as that returned by \fBpbm_readpbmrow()\fP. .PP \fBpbm_writepbm()\fP writes the header and all data for a PBM image to a PBM file. This function combines \fBpbm_writepbminit()\fP and \fBpbm_writepbmrow()\fP. .UN miscellaneous .SS MISCELLANEOUS .PP \fBpbm_nextimage()\fP positions a PBM input file to the next image in it (so that a subsequent \fBpbm_readpbminit()\fP reads its header). .PP Immediately before a call to \fBpbm_nextimage()\fP, 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 \fBpbm_readpbmrow() \fP of the last row in the image). .PP Note that in the raw PNM and PAM format, the next image always starts immediately after the previous image, so all \fBpbm_nextimage()\fP really does is test whether there is a next image or the file is positioned at end-of-file. In plain PNM, though, there may be white space between images. .PP If \fBpbm_nextimage() \fP successfully positions to the next image, it returns \fB*\fP\fIeofP\fP false (0). If there is no next image in the file, it returns \fB*\fP\fIeofP\fP true . If it can't position or determine the file status because of a file error, it .UR liberror.html#error throws an error .UE \&. .PP \fBpbm_check()\fP checks for the common file integrity error where the file is the wrong size to contain all the image data. \fBpbm_check()\fP assumes the file is positioned after an image header (as if \fBpbm_readpbminit() \fP 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, \fBpbm_check()\fP causes the program t .UR liberror.html#error throws an error .UE \&. Otherwise, it returns one of the following values (enumerations of the \fBenum pm_check_code\fP type) as \fB*\fP\fIretval\fP: .TP \fBPM_CHECK_OK\fP The file's size is exactly what is required to hold the image raster. .TP \fBPM_CHECK_UNKNOWN_TYPE\fP \fIformat\fP is not a format whose size \fBpbm_check()\fP can anticipate. The only format with which \fBpbm_check()\fP can deal is raw PBM format. .TP \fBPM_CHECK_TOO_LONG\fP The file is longer than it needs to be to contain the image raster. The extra data might be another image. .TP \fBPM_CHECK_UNCHECKABLE\fP The file is not a kind that has a predictable size, so there is no simple way for \fBpbm_check()\fP to know if it is the right size. Only a regular file has predictable size. A pipe is a common example of a file that does not. .PP \fIcheck_type\fP must have the value \fBPM_CHECK_BASIC \fP (an enumerated value of the \fBpm_check_type\fP enumerated type). Otherwise, the effect of \fBpbm_check()\fP is unpredictable. This argument exists for future backward compatible expansion of the function of \fBpbm_check()\fP. .UN seealso .SH SEE ALSO .BR "libpgm" (1)\c \&, .BR "libppm" (1)\c \&, .BR "libpnm" (1)\c \&, .BR "pbm" (1)\c \& .UN author .SH AUTHOR Copyright (C) 1989, 1991 by Tony Hansen and Jef Poskanzer. .SH DOCUMENT SOURCE This manual page was generated by the Netpbm tool 'makeman' from HTML source. The master documentation is at .IP .B http://netpbm.sourceforge.net/doc/libpbm.html .PP