1User manual for old pnm funcLtiibornasr(y3)FunctionUsseMranmuaanlual for old pnm functions(3)
2
3
4
6 libpnm - libnetpbm functions to read and write PNM image files
7
8
10 #include <netpbm/pnm.h>
11
12 void pnm_init( int *argcP, char *argv[] );
13
14 xel ** pnm_allocarray( int cols, int rows);
15
16 xel * pnm_allocrow( int cols);
17
18 void pnm_freearray( xel **xels, int rows);
19
20 void pnm_freerow( xel *xelrow);
21
22 void pnm_readpnminit( FILE *fp, int *colsP, int *rowsP, xelval *max‐
23 valP, int *formatP );
24
25 void pnm_readpnmrow( FILE *fp, xel *xelrow, int cols, xelval maxval,
26 int format );
27
28 xel ** pnm_readpnm( FILE *fp, int *colsP, int *rowsP, xelval *maxvalP,
29 int* formatP );
30
31 void pnm_writepnminit( FILE * fp , int cols, int rows, xelval maxval,
32 int format, int forceplain);
33
34 void pnm_writepnmrow( FILE *fp, xel *xelrow, int cols, xelval maxval,
35 int format, int forceplain );
36
37 void pnm_writepnm( FILE *fp, xel ** xels, int cols, int rows, xelval
38 maxval, int format, int forceplain );
39
40 void pnm_nextimage(FILE * file,
41 int * const eofP);
42
43 void pnm_check( FILE * file, const enum pm_check_type check_type, const
44 int format, const int cols, const int rows, const xelval maxval, enum
45 pm_check_code *retvalP);
46
47 void pnm_promoteformatrow( xel *xelrow, int cols, xelval maxval, int
48 format, xelval newmaxval, int newformat);
49
50 void pnm_promoteformat( xel **xels, int cols, xelval maxval, int for‐
51 mat, xelval newmaxval, int newformat);
52
53 xel pnm_whitexel( xelval maxval, int format);
54
55 xel pnm_blackxel( xelval maxval, int format);
56
57 void pnm_invertxel( xel *x, xelval maxval, int format);
58
59 xel pnm_backgroundxelrow( xel *xelrow, int cols, xelval maxval, int
60 format);
61
62 xel pnm_backgroundxel( xel **xels, int cols, int rows, xelval maxval,
63 int format);
64
65 typedef ... xelval;
66
67 typedef ... xel;
68
69 #define PNM_ASSIGN1(x,v) ...
70
71 #define PNM_GET1(x) ...
72
73 #define PNM_EQUAL(x,y) ...
74
75 #define PNM_FORMAT_TYPE(format) ...
76
77
79 These library functions are part of Netpbm(1).
80
81
82
83 TYPES AND CONSTANTS
84 Each xel contains three xelvals, each of which should contain only the
85 values between 0 and PNM_MAXMAXVAL, inclusive.
86
87
88 XEL MANIPULATIONS
89 The PNM_GET1 macro extracts a single value from an xel, when ou know
90 it's from a PBM or PGM file. When it's from a PPM file, use
91 PPM_GETR(), PPM_GETG(), and PPM_GETB().
92
93 The PNM_ASSIGN1 macro assigns a single value to an xel, when you know
94 it's from a PBM or PGM file. When it's from a PPM file, use
95 PPM_ASSIGN.
96
97 The PNM_EQUAL macro checks two xels for equality. The PNM_FORMAT_TYPE
98 macro computes a format type code from a format code. The format types
99 are PBM, PGM, PPM, and PAM. But note that PBM, PGM, and PPM each are
100 two different formats: a plain one and a raw one. So there are four
101 format types, but seven formats. PNM_FORMAT_TYPE does not work on the
102 PAM format code.
103
104 pnm_whitexel() and pnm_blackxel() return a white or black xel, respec‐
105 tively, for the given maxval and format.
106
107 pnm_invertxel() inverts an xel.
108
109
110 INITIALIZATION
111 pnm_init() is identical to pm_proginit.
112
113 pnm_init() is obsolete. Use pm_proginit() instead.
114
115
116 MEMORY MANAGEMENT
117 pnm_allocarray() allocates space for an array of xels. pnm_freearray()
118 frees an array space allocated by pnm_allocarray() or pnm_readpnm().
119
120 pnm_allocrow() allocates space for a row of a PNM image. pnm_freerow()
121 frees it.
122
123
124
125 READING PNM FILES
126 pnm_readpnminit() is similar to pnm_readpaminit(), but reads only PNM
127 images and has a different parameter list.
128
129 pnm_readpnmrow() is similar to pnm_readpamrow() but only works on PNM
130 images and has a different parameter list and returns the row as an
131 array of xels instead of tuples.
132
133 pnm_readpnm() is similar to pnm_readpam() except that it reads only PNM
134 images and uses a different parameter list and returns an array of rows
135 such that pnm_readpnmrow() would return rather than such that pnm_read‐
136 pamrow() would return.
137
138
139
140 WRITING FILES
141 pnm_writepnminit() is similar to pnm_writepaminit() except that it can
142 write only a PNM header and has a different parameter list.
143
144 forceplain is a binary value. True (nonzero) means to write the image
145 in the plain (ASCII) version of the selected format. False (zero)
146 means to write it in the raw (binary) version of the selected format.
147 See PNMformatspecification(1).
148
149 pnm_writepnmrow() is similar to pnm_writepamrow() except that it works
150 only on PNM images and has a different parameter list and takes an
151 array of xels instead of an array of tuples. See the description of
152 forceplain above.
153
154 pnm_writepnm() is similar to pnm_writepam() except that it works only
155 on PNM image, has a different parameter list, and takes an array of
156 rows of xels instead of an array of rows of tuples. See the descrip‐
157 tion of forceplain above.
158
159
160
161 FORMAT PROMOTION
162 pnm_promoteformatrow() promotes a row of xels from one maxval and for‐
163 mat to a new set. Use this when you are combining multiple anymaps of
164 different types - just take the maximum of the maxvals and the maximum
165 of the formats, and promote them all to that.
166
167 pnm_promoteformat() promotes an entire anymap.
168
169
170 MISCELLANEOUS
171 pnm_nextimage() positions a PNM input file to the next image in it (so
172 that a subsequent pnm_readpnminit() reads its header).
173
174 pnm_nextimage() is analogous to pbm_nextimage(), but works on PPM, PGM,
175 and PBM files.
176
177 pnm_check() is similar to pnm_checkpam() except it works only on PNM
178 images.
179
180 pnm_check() is identical to ppm_check().
181
182 pnm_backgroundxelrow() figures out an appropriate background xel based
183 on the row of xels xelrow, which is cols xels wide, has maxval maxval,
184 and represents an image with format format.
185
186 This estimate works best when the row is the top or bottom row of the
187 image.
188
189 pnm_backgroundxel() does the same thing as pnm_backgroundxelrow(),
190 except based on an entire image instead of just one row. This tends to
191 do a slightly better job than pnmbackgroundxelrow().
192
193
195 Libnetpbm(1), LibnetpbmUser'sGuide(1), LibnetpbmDirectory[1m(1), pbm(1),
196 pgm(1), ppm(1), pam(1), libpbm(1), libpgm(1), libppm(1)
197
198
200 Copyright (C) 1989, 1991 by Tony Hansen and Jef Poskanzer.
201
202
203
204netpbm documentation 8 SeptemberU2s0e0r7manual for old pnm functions(3)