1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>User manual for old pnm functions</TITLE>
<META NAME="manual_section" CONTENT="3">
</HEAD>
<BODY>
<H1>pnm Functions</H1>
Updated: 8 September 2007
<BR>
<A HREF="#index">Table Of Contents</A>
<H2>NAME</H2>
libpnm - libnetpbm functions to read and write PNM image files
<H2 id="synopsis">SYNOPSIS</H2>
<B>#include <netpbm/pnm.h></B>
<P>
<B>void pnm_init(</B>
<B>int *</B><I>argcP</I><B>,</B>
<B>char *</B><I>argv</I><B>[]</B>
<B>);</B>
<P>
<B>xel ** pnm_allocarray(</B>
<B>int </B><I>cols</I><B>,</B>
<B>int </B><I>rows</I><B>);</B>
<P>
<B>xel * pnm_allocrow(</B>
<B>int </B><I>cols</I><B>);</B>
<P>
<B>void pnm_freearray(</B>
<B>xel **</B><I>xels</I><B>,</B>
<B>int </B><I>rows</I><B>);</B>
<P>
<B>void pnm_freerow(</B>
<B>xel *</B><I>xelrow</I><B>);</B>
<P>
<B>void pnm_readpnminit( </B>
<B>FILE *</B><I>fp</I><B>,</B>
<B>int *</B><I>colsP</I><B>,</B>
<B>int *</B><I>rowsP</I><B>,</B>
<B>xelval *</B><I>maxvalP</I><B>,</B>
<B>int *</B><I>formatP</I><B> );</B>
<P>
<B>void pnm_readpnmrow( </B>
<B>FILE *</B><I>fp</I><B>,</B>
<B>xel *</B><I>xelrow</I><B>,</B>
<B>int </B><I>cols</I><B>,</B>
<BR>
<B>xelval </B><I>maxval</I><B>,</B>
<B>int </B><I>format</I><B> );</B>
<P>
<B>xel ** pnm_readpnm( </B>
<B>FILE *</B><I>fp</I><B>,</B>
<B>int *</B><I>colsP</I><B>,</B>
<B>int *</B><I>rowsP</I><B>,</B>
<BR>
<B>xelval *</B><I>maxvalP</I><B>, int</B><I>*</I><B> formatP </B><I>);</I>
<P>
<B>void pnm_writepnminit( </B>
<B>FILE * fp , </B>
<B>int </B><I>cols</I><B>,</B>
<B>int </B><I>rows</I><B>,</B>
<B>xelval </B><I>maxval</I><B>,</B>
<B>int </B><I>format</I><B>,</B>
<B>int </B><I>forceplain</I><B>);</B>
<P>
<B>void pnm_writepnmrow( </B>
<B>FILE *</B><I>fp</I><B>,</B>
<B>xel *</B><I>xelrow</I><B>,</B>
<B>int cols</B><I>,</I>
<B>xelval </B><I>maxval</I><B>,</B>
<B>int </B><I>format</I><B>,</B>
<B>int </B><I>forceplain</I><B> );</B>
<P>
<B>void pnm_writepnm( </B>
<B>FILE *</B><I>fp</I><B>,</B>
<B>xel ** </B><I>xels</I><B>,</B>
<B>int </B><I>cols</I><B>,</B>
<B>int </B><I>rows</I><B>,</B>
<B>xelval </B><I>maxval</I><B>,</B>
<B>int </B><I>format</I><B>,</B>
<B>int </B><I>forceplain</I><B> );</B>
<P>
<B>void pnm_nextimage(</B><B>FILE *</B> <I>file</I><B>,</B>
<B>int * const</B> <I>eofP</I><B>);</B>
<P>
<B>void pnm_check(</B>
<B>FILE * </B><I>file</I><B>,</B>
<B>const enum pm_check_type </B><I>check_type</I><B>,</B>
<B>const int </B><I>format</I><B>,</B>
<B>const int </B><I>cols</I><B>,</B>
<B>const int </B><I>rows</I><B>,</B>
<B>const xelval </B><I>maxval</I><B>,</B>
<B>enum pm_check_code *</B><I>retvalP</I><B>);</B>
<P>
<B>void pnm_promoteformatrow( </B>
<B>xel *</B><I>xelrow</I><B>,</B>
<B>int </B><I>cols</I><B>,</B>
<B>xelval </B><I>maxval</I><B>,</B>
<B>int </B><I>format</I><B>,</B>
<B>xelval </B><I>newmaxval</I><B>,</B>
<B>int </B><I>newformat</I><B>);</B>
<P>
<B>void pnm_promoteformat( </B>
<B>xel **</B><I>xels</I><B>,</B>
<B>int </B><I>cols</I><B>,</B>
<B>xelval </B><I>maxval</I><B>,</B>
<B>int </B><I>format</I><B>,</B>
<B>xelval </B><I>newmaxval</I><B>,</B>
<B>int </B><I>newformat</I><B>);</B>
<P>
<B>xel pnm_whitexel( </B>
<B>xelval </B><I>maxval</I><B>,</B>
<B>int </B><I>format</I><B>);</B>
<P>
<B>xel pnm_blackxel( </B>
<B>xelval </B><I>maxval</I><B>,</B>
<B>int </B><I>format</I><B>);</B>
<P>
<B>void pnm_invertxel( </B>
<B>xel *</B><I>x</I><B>,</B>
<B>xelval </B><I>maxval</I><B>,</B>
<B>int </B><I>format</I><B>);</B>
<P>
<B>xel pnm_backgroundxelrow( </B>
<B>xel *</B><I>xelrow</I><B>,</B>
<B>int </B><I>cols</I><B>,</B>
<B>xelval </B><I>maxval</I><B>,</B>
<B>int </B><I>format</I><B>);</B>
<P>
<B>xel pnm_backgroundxel( </B>
<B>xel **</B><I>xels</I><B>,</B>
<B>int </B><I>cols</I><B>,</B>
<B>int </B><I>rows</I><B>,</B>
<B>xelval </B><I>maxval</I><B>,</B>
<B>int </B><I>format</I><B>);</B>
<P><B>typedef ... xelval;</B>
<P><B>typedef ... xel;</B>
<P>
<B>#define </B>
<B>PNM_ASSIGN1(</B><I>x</I><B>,</B><I>v</I><B>)</B>
<B>...</B>
<P>
<B>#define </B>
<B>PNM_GET1(</B><I>x</I><B>)</B>
<B>...</B>
<P>
<B>#define </B>
<B>PNM_EQUAL(</B><I>x</I><B>,</B><I>y</I><B>)</B>
<B>...</B>
<P>
<B>#define </B>
<B>PNM_FORMAT_TYPE(</B><I>format</I><B>)</B>
<B>...</B>
<H2 id="description">DESCRIPTION</H2>
<p>These library functions are part of <a href="index.html">Netpbm</a>.
<H3 id="types">TYPES AND CONSTANTS</H3>
<P>Each <B>xel</B> contains three <B>xelval</B>s, each of which should
contain only the values between <B>0</B> and <B>PNM_MAXMAXVAL</B>,
inclusive.
<H3 id="xel">XEL MANIPULATIONS</H3>
<p>The <B>PNM_GET1</B> macro extracts a single value from an xel, when
ou know it's from a PBM or PGM file. When it's from a PPM file, use
<B>PPM_GETR()</B>, <B>PPM_GETG()</B>, and <B>PPM_GETB()</B>.
<P>The <B>PNM_ASSIGN1</B> macro assigns a single value to an xel, when
you know it's from a PBM or PGM file. When it's from a PPM file, use
<B>PPM_ASSIGN</B>.
The <B>PNM_EQUAL</B> macro checks two xels for equality. The
<B>PNM_FORMAT_TYPE</B> macro computes a
format type code from a format code. The format types are PBM, PGM,
PPM, and PAM. But note that PBM, PGM, and PPM each are two different
formats: a plain one and a raw one. So there are four format types,
but seven formats. <B>PNM_FORMAT_TYPE</B> does not work on the PAM
format code.
<B>pnm_whitexel()</B> and <B>pnm_blackxel()</B> return a white or
black xel, respectively, for the given <I>maxval</I> and
<I>format</I>.
<P><B>pnm_invertxel()</B> inverts an xel.
<H3 id="initialization">INITIALIZATION</H3>
<P><b>pnm_init()</b> is identical to <b>pm_proginit</b>.
<p><b>pnm_init()</b> is obsolete. Use <b>pm_proginit()</b> instead.
<H3 id="memorymanagement">MEMORY MANAGEMENT</H3>
<P><B>pnm_allocarray()</B> allocates space for an array of xels.
<B>pnm_freearray()</B> frees an array space allocated by
<B>pnm_allocarray()</B> or <B>pnm_readpnm()</B>.
<P><B>pnm_allocrow()</B> allocates space for a row of a PNM image.
<B>pnm_freerow()</B> frees it.
<H3 id="reading">READING PNM FILES</H3>
<P><B>pnm_readpnminit()</B> is similar to <B>pnm_readpaminit()</B>,
but reads only PNM images and has a different parameter list.
<P><B>pnm_readpnmrow()</B> is similar to <B>pnm_readpamrow()</B>
but only works on PNM images and has a different parameter list and returns
the row as an array of xels instead of tuples.
<P><B>pnm_readpnm()</B> is similar to <B>pnm_readpam()</B> except that
it reads only PNM images and uses a different parameter list and
returns an array of rows such that <B>pnm_readpnmrow()</B> would
return rather than such that <B>pnm_readpamrow()</B> would return.
<H3 id="writing">WRITING FILES</H3>
<P><B>pnm_writepnminit()</B> is similar to <B>pnm_writepaminit()</B>
except that it can write only a PNM header and has a different
parameter list.
<P><i>forceplain</i> is a binary value. True (nonzero) means to write
the image in the plain (ASCII) version of the selected format. False
(zero) means to write it in the raw (binary) version of the selected
format. See <a href="pnm.html">PNM format specification</a>.
<P><B>pnm_writepnmrow()</B> is similar to <B>pnm_writepamrow()</B>
except that it works only on PNM images and has a different parameter
list and takes an array of xels instead of an array of tuples. See
the description of <I>forceplain </I> above.
<P><B>pnm_writepnm()</B> is similar to <B>pnm_writepam()</B> except
that it works only on PNM image, has a different parameter list, and
takes an array of rows of xels instead of an array of rows of tuples.
See the description of <I>forceplain</I> above.
<H3 id="promotion">FORMAT PROMOTION</H3>
<B>pnm_promoteformatrow()</B> promotes a row of xels from one maxval
and format to a new set. Use this when you are combining multiple
anymaps of different types - just take the maximum of the maxvals and
the maximum of the formats, and promote them all to that.
<P><B>pnm_promoteformat()</B> promotes an entire anymap.
<H3 id="miscellaneous">MISCELLANEOUS</H3>
<P><B>pnm_nextimage()</B> positions a PNM input file to the next image
in it (so that a subsequent <B>pnm_readpnminit()</B> reads its
header).
<P><B>pnm_nextimage()</B> is analogous to <B>pbm_nextimage()</B>, but
works on PPM, PGM, and PBM files.
<P> <B>pnm_check()</B> is similar to <B>pnm_checkpam()</B> except it
works only on PNM images.
<P><B>pnm_check()</B> is identical to <B>ppm_check()</B>.
<P><B>pnm_backgroundxelrow()</B> figures out an appropriate background
xel based on the row of xels <I>xelrow</I>, which is <I>cols</I> xels
wide, has maxval <I>maxval</I>, and represents an image with format
<I>format</I>.
<P>This estimate works best when the row is the top or bottom row of
the image.
<P><B>pnm_backgroundxel()</B> does the same thing as
<B>pnm_backgroundxelrow()</B>, except based on an entire image instead
of just one row. This tends to do a slightly better job than
<B>pnmbackgroundxelrow()</B>.
<H2 id="seealso">SEE ALSO</H2>
<B><A HREF="libnetpbm.html">Libnetpbm</A></B>,
<B><A HREF="libnetpbm_ug.html">Libnetpbm User's Guide</A></B>,
<B><A HREF="libnetpbm_dir.html">Libnetpbm Directory</A></B>,
<B><A HREF="pbm.html">pbm</A></B>,
<B><A HREF="pgm.html">pgm</A></B>,
<B><A HREF="ppm.html">ppm</A></B>,
<B><A HREF="pam.html">pam</A></B>,
<B><A HREF="libpbm.html">libpbm</A></B>,
<B><A HREF="libpgm.html">libpgm</A></B>,
<B><A HREF="libppm.html">libppm</A></B>
<H2 id="author">AUTHOR</H2>
Copyright (C) 1989, 1991 by Tony Hansen and Jef Poskanzer.
<HR>
<H2 id="index">Table Of Contents</H2>
<UL>
<LI><A HREF="#synopsis">SYNOPSIS</A>
<LI><A HREF="#description">DESCRIPTION</A>
<UL>
<LI><A HREF="#types">TYPES AND CONSTANTS</A>
<LI><A HREF="#xel">XEL MANIPULATIONS</A>
<LI><A HREF="#initialization">INITIALIZATION</A>
<LI><A HREF="#memorymanagement">MEMORY MANAGEMENT</A>
<LI><A HREF="#reading">READING PNM FILES</A>
<LI><A HREF="#writing">WRITING FILES</A>
<LI><A HREF="#promotion">FORMAT PROMOTION</A>
<LI><A HREF="#miscellaneous">MISCELLANEOUS</A>
</UL>
<LI><A HREF="#seealso">SEE ALSO</A>
<LI><A HREF="#author">AUTHOR</A>
</UL>
</BODY>
</HTML>
|