1User manual for old pgm funcLtiibornasr(y3)FunctionUsseMranmuaanlual for old pgm functions(3)
2
3
4
6 libpgm - libnetpbm functions to read and write PGM image files
7
8
10 #include <netpbm/pgm.h>
11
12 void pgm_init( int *argcP, char *argv[] );
13
14 gray ** pgm_allocarray( int cols, int rows );
15
16 gray * pgm_allocrow( intcols );
17
18 void pgm_freearray( gray **grays, introws );
19
20 void pgm_freerow( gray *grayrow);
21
22 void pgm_readpgminit( FILE *fp, int *colsP, int *rowsP, gray *maxvalP,
23 int *formatP );
24
25 void pgm_readpgmrow( FILE *fp, gray *grayrow, int cols, gray maxval,
26 int format );
27
28 gray ** pgm_readpgm( FILE *fp, int *colsP, int *rowsP, gray *maxvalP );
29
30 void pgm_writepgminit( FILE * fp , int cols, int rows, gray maxval,
31 int forceplain );
32
33 void pgm_writepgmrow( FILE *fp, gray *grayrow, int cols, gray maxval,
34 int forceplain );
35
36 void pgm_writepgm( FILE *fp, gray ** grays, int cols, int rows, gray
37 maxval, int forceplain );
38
39 void pgm_writepgm( FILE *fp, gray **grays, int cols, int rows, gray
40 maxval, int forceplain );
41
42 void pgm_nextimage( FILE *file, int * const eofP);
43
44 void pgm_check( FILE * file, const enum pm_check_type check_type, const
45 int format, const int cols, const int rows, const int maxval, enum
46 pm_check_code * const retval);
47
48 typedef ... gray;
49
50 #define PGM_MAXMAXVAL ...
51
52 #define PGM_OVERALLMAXVAL ...
53
54 #define PGM_FORMAT ...
55
56 #define RPGM_FORMAT ...
57
58 #define PGM_TYPE PGM_FORMAT
59
60 #define
61
62 PGM_FORMAT_TYPE(format) ...
63
64
66 These library functions are part of Netpbm(1).
67
68
69 TYPES AND CONSTANTS
70 Each gray should contain only the values between 0 and PGM_OVERALLMAX‐
71 VAL.
72
73 PGM_OVERALLMAXVAL is the maximum value of a maxval in a PGM file.
74 PGM_MAXMAXVAL is the maximum value of a maxval in a PGM file that is
75 compatible with the PGM format as it existed before April 2000. It is
76 also the maximum value of a maxval that results in the minimum possible
77 raster size for a particular image. I.e an image with a maxval higher
78 than PGM_MAXMAXVAL cannot be read or generated by old PGM processing
79 programs and requires more file space.
80
81 PGM_FORMAT is the format code for a Plain PGM format image file.
82 RPGM_FORMAT is the format code for a Raw PGM format image file.
83 PGM_TYPE is the format type code for the PGM formats. PGM_FORMAT_TYPE
84 is a macro that generates code to compute the format type code of a PBM
85 or PGM format from the format code which is its argument.
86
87
88 INITIALIZATION
89 pgm_init() is obsolete (at least since Netpbm 9.25 (March 2002)). Use
90 pm_proginit() ⟨libpm.html#initialization⟩ instead.
91
92 pgm_init() is identical to pm_proginit.
93
94
95
96 MEMORY MANAGEMENT
97 pgm_allocarray() allocates an array of grays.
98
99 pgm_allocrow() allocates a row of the given number of grays.
100
101 pgm_freearray() frees the array allocated with pgm_allocarray() con‐
102 taining the given number of rows.
103
104 pgm_freerow() frees a row of grays allocated with pgm_allocrow().
105
106
107 READING FILES
108 If a function in this section is called on a PBM format file, it trans‐
109 lates the PBM file into a PGM file on the fly and functions as if it
110 were called on the equivalent PGM file. The format value returned by
111 pgm_readpgminit() is, however, not translated. It represents the
112 actual format of the PBM file.
113
114 pgm_readpgminit() reads the header of a PGM file, returning all the
115 information from the header and leaving the file positioned just after
116 the header.
117
118 pgm_readpgmrow() reads a row of grays into the grayrow
119 array. format, cols, and maxval are the values returned by
120 pgm_readpgminit().
121
122 pgm_readpgm() reads an entire PGM image into memory, returning the
123 allocated array as its return value and returning the information from
124 the header as rows, cols, and maxval. This function combines
125 pgm_readpgminit(), pgm_allocarray(), and pgm_readpgmrow().
126
127 pgm_readpgminit() and pgm_readpgm abort the program with a message to
128 Standard Error if the PGM image header is not syntactically valid,
129 including if it contains a number too large to be processed using the
130 system's normal data structures (to wit, a number that won't fit in a C
131 'int').
132
133
134
135 WRITING FILES
136 pgm_writepgminit() writes the header for a PGM file and leaves it posi‐
137 tioned just after the header.
138
139 forceplain is a logical value that tells pgm_writepgminit() to write a
140 header for a plain PGM format file, as opposed to a raw PGM format
141 file.
142
143 pgm_writepgmrow() writes the row grayrow to a PGM file. For meaningful
144 results, cols, maxval, and forceplain must be the same as was used with
145 pgm_writepgminit().
146
147 pgm_writepgm() write the header and all data for a PGM image. This
148 function combines pgm_writepgminit() and pgm_writepgmrow().
149
150
151 MISCELLANEOUS
152 pgm_nextimage() positions a PGM input file to the next image in it (so
153 that a subsequent pgm_readpgminit() reads its header).
154
155 pgm_nextimage() is analogous to pbm_nextimage(), but works on PGM and
156 PBM files.
157
158 pgm_check() checks for the common file integrity error where the file
159 is the wrong size to contain all the image data.
160
161 pgm_check() is analogous to pbm_check(), but works on PGM and PBM
162 files.
163
164
166 libpbm(1), libppm(1), libpnm(1)
167
169 This manual page was generated by the Netpbm tool 'makeman' from HTML
170 source. The master documentation is at
171
172 http://netpbm.sourceforge.net/doc/libpgm.html
173
174netpbm documentation 8 SeptemberU2s0e0r7manual for old pgm functions(3)