1User manual for old pnm funcLtiibornasr(y3)FunctionUsseMranmuaanlual for old pnm functions(3)
2
3
4

NAME

6       libpnm - libnetpbm functions to read and write PNM image files
7
8

SYNOPSIS

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

DESCRIPTION

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 obsolete (at least since Netpbm 9.25 (March 2002)).   Use
112       pm_proginit() ⟨libpm.html#initialization⟩  instead.
113
114       pnm_init() is identical to pm_proginit.
115
116
117   MEMORY MANAGEMENT
118       pnm_allocarray() allocates space for an array of xels.  pnm_freearray()
119       frees an array space allocated by pnm_allocarray() or pnm_readpnm().
120
121       pnm_allocrow() allocates space for a row of a PNM image.  pnm_freerow()
122       frees it.
123
124
125
126   READING PNM FILES
127       pnm_readpnminit()  is  similar to pnm_readpaminit(), but reads only PNM
128       images and has a different parameter list.
129
130       pnm_readpnmrow() is similar to pnm_readpamrow() but only works  on  PNM
131       images  and  has  a  different parameter list and returns the row as an
132       array of xels instead of tuples.
133
134       pnm_readpnm() is similar to pnm_readpam() except that it reads only PNM
135       images and uses a different parameter list and returns an array of rows
136       such that pnm_readpnmrow() would return rather than such that pnm_read‐
137       pamrow() would return.
138
139
140
141   WRITING FILES
142       pnm_writepnminit()  is similar to pnm_writepaminit() except that it can
143       write only a PNM header and has a different parameter list.
144
145       forceplain is a binary value.  True (nonzero) means to write the  image
146       in  the  plain  (ASCII)  version  of the selected format.  False (zero)
147       means to write it in the raw (binary) version of the  selected  format.
148       See PNM format specification(1).
149
150       pnm_writepnmrow()  is similar to pnm_writepamrow() except that it works
151       only on PNM images and has a different  parameter  list  and  takes  an
152       array  of  xels  instead of an array of tuples.  See the description of
153       forceplain  above.
154
155       pnm_writepnm() is similar to pnm_writepam() except that it  works  only
156       on  PNM  image,  has  a different parameter list, and takes an array of
157       rows of xels instead of an array of rows of tuples.  See  the  descrip‐
158       tion of forceplain above.
159
160
161
162   FORMAT PROMOTION
163       pnm_promoteformatrow()  promotes a row of xels from one maxval and for‐
164       mat to a new set.  Use this when you are combining multiple anymaps  of
165       different  types - just take the maximum of the maxvals and the maximum
166       of the formats, and promote them all to that.
167
168       pnm_promoteformat() promotes an entire anymap.
169
170
171   MISCELLANEOUS
172       pnm_nextimage() positions a PNM input file to the next image in it  (so
173       that a subsequent pnm_readpnminit() reads its header).
174
175       pnm_nextimage() is analogous to pbm_nextimage(), but works on PPM, PGM,
176       and PBM files.
177
178        pnm_check() is similar to pnm_checkpam() except it works only  on  PNM
179       images.
180
181       pnm_check() is identical to ppm_check().
182
183       pnm_backgroundxelrow()  figures out an appropriate background xel based
184       on the row of xels xelrow, which is cols xels wide, has maxval  maxval,
185       and represents an image with format format.
186
187       This  estimate  works best when the row is the top or bottom row of the
188       image.
189
190       pnm_backgroundxel() does  the  same  thing  as  pnm_backgroundxelrow(),
191       except based on an entire image instead of just one row.  This tends to
192       do a slightly better job than pnmbackgroundxelrow().
193
194

SEE ALSO

196       Libnetpbm(1),  Libnetpbm  User's  Guide(1),   Libnetpbm   Directory(1),
197       pbm(1), pgm(1), ppm(1), pam(1), libpbm(1), libpgm(1), libppm(1)
198
199

AUTHOR

201       Copyright (C) 1989, 1991 by Tony Hansen and Jef Poskanzer.
202

DOCUMENT SOURCE

204       This  manual  page was generated by the Netpbm tool 'makeman' from HTML
205       source.  The master documentation is at
206
207              http://netpbm.sourceforge.net/doc/libpnm.html
208
209netpbm documentation           8 SeptemberU2s0e0r7manual for old pnm functions(3)
Impressum