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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN">
<html>
<head>
<title>User manual for old pgm functions</title>
<meta name="manual_section" content="3">
</head>
<body>
<h1>pgm Functions</h1>
Updated: 08 September 2007
<br>
<a href="#index">Table Of Contents</a>
<h2>NAME</h2>
libpgm - libnetpbm functions to read and write PGM image files
<h2 id="synopsis">SYNOPSIS</h2>
<b>#include <netpbm/pgm.h></b>
<p>
<b>void pgm_init( </b>
<b>int *</b><i>argcP</i><b>,</b>
<b>char *</b><i>argv</i><b>[]</b>
<b>);</b>
<p>
<b>gray ** pgm_allocarray(</b>
<b>int </b><i>cols</i><b>,</b>
<b>int </b><i>rows</i><b> );</b>
<p>
<b>gray * pgm_allocrow(</b>
<b>int</b><i>cols</i><b> );</b>
<p>
<b>void pgm_freearray(</b>
<b>gray **</b><i>grays</i><b>,</b>
<b>int</b><i>rows</i><b> );</b>
<p>
<b>void pgm_freerow(</b>
<b>gray *</b><i>grayrow</i><b>);</b>
<p>
<b>void pgm_readpgminit( </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>gray *</b><i>maxvalP</i><b>,</b>
<b>int *</b><i>formatP</i><b> );</b>
<p>
<b>void pgm_readpgmrow( </b>
<b>FILE *</b><i>fp</i><b>,</b>
<b>gray *</b><i>grayrow</i><b>,</b>
<b>int </b><i>cols</i><b>,</b>
<b>gray </b><i>maxval</i><b>,</b>
<b>int </b><i>format</i><b> );</b>
<p>
<b>gray ** pgm_readpgm( </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>gray *</b><i>maxvalP</i><b> );</b>
<p>
<b>void pgm_writepgminit( </b>
<b>FILE * fp , </b>
<b>int </b><i>cols</i><b>,</b>
<b>int </b><i>rows</i><b>,</b>
<b>gray </b><i>maxval</i><b>,</b>
<b>int </b><i>forceplain</i><b> );</b>
<p>
<b>void pgm_writepgmrow( </b>
<b>FILE *</b><i>fp</i><b>,</b>
<b>gray *</b><i>grayrow</i><b>,</b>
<b>int cols</b><i>,</i>
<b>gray </b><i>maxval</i><b>,</b>
<b>int </b><i>forceplain</i><b> );</b>
<p>
<b>void pgm_writepgm( </b>
<b>FILE *</b><i>fp</i><b>,</b>
<b>gray ** </b><i>grays</i><b>,</b>
<b>int </b><i>cols</i><b>,</b>
<b>int </b><i>rows</i><b>,</b>
<b>gray </b><i>maxval</i><b>,</b>
<b>int </b><i>forceplain</i><b> );</b>
<p>
<b>void pgm_writepgm( </b>
<b>FILE *</b><i>fp</i><b>,</b>
<b>gray **</b><i>grays</i><b>,</b>
<b>int </b><i>cols</i><b>,</b>
<b>int </b><i>rows</i><b>,</b>
<b>gray </b><i>maxval</i><b>,</b>
<b>int </b><i>forceplain</i><b> );</b>
<p>
<b>void pgm_nextimage(</b>
<b>FILE *</b><i>file</i><b>,</b>
<b>int * const </b><i>eofP</i><b>);</b>
<p>
<b>void pgm_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 int </b><i>maxval</i><b>,</b>
<b>enum pm_check_code * const </b><i>retval</i><b>);</b>
<p>
<b>typedef ... gray;</b>
<p>
<b>#define PGM_MAXMAXVAL ...</b>
<p>
<b>#define PGM_OVERALLMAXVAL ...</b>
<p>
<b>#define PGM_FORMAT ...</b>
<p>
<b>#define RPGM_FORMAT ...</b>
<p>
<b>#define PGM_TYPE PGM_FORMAT</b>
<p>
<b>#define </b>
<b>PGM_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>gray</b> should contain only the values between <b>0</b>
and <b>PGM_OVERALLMAXVAL</b>.
<p><b>PGM_OVERALLMAXVAL</b> is the maximum value of a maxval in a PGM
file. <b>PGM_MAXMAXVAL</b> is the maximum value of a maxval in a PGM
file that is compatible with the PGM format as it existed before April
2000. It is also the maximum value of a maxval that results in the
minimum possible raster size for a particular image. I.e an image
with a maxval higher than <b>PGM_MAXMAXVAL</b> cannot be read or
generated by old PGM processing programs and requires more file space.
<p><b>PGM_FORMAT </b> is the format code for a Plain PGM format image
file. <b>RPGM_FORMAT</b> is the format code for a Raw PGM format
image file. <b>PGM_TYPE </b> is the format type code for the PGM
formats. <b>PGM_FORMAT_TYPE</b> is a macro that generates code to
compute the format type code of a PBM or PGM format from the format
code which is its argument.
<h3 id="initialization">INITIALIZATION</h3>
<p><b>pgm_init()</b> is obsolete (at least since Netpbm 9.25 (March 2002)).
Use <a href="libpm.html#initialization"><b>pm_proginit()</b></a> instead.
<p><b>pgm_init()</b> is identical to <b>pm_proginit</b>.
<h3 id="memorymanagement">MEMORY MANAGEMENT</h3>
<b>pgm_allocarray()</b> allocates an array of grays.
<p><b>pgm_allocrow()</b> allocates a row of the given number of grays.
<p><b>pgm_freearray()</b> frees the array allocated with
<b>pgm_allocarray()</b> containing the given number of rows.
<p><b>pgm_freerow()</b> frees a row of grays allocated with
<b>pgm_allocrow()</b>.
<h3 id="reading">READING FILES</h3>
<p>If a function in this section is called on a PBM format file, it
translates the PBM file into a PGM file on the fly and functions as if
it were called on the equivalent PGM file. The <i>format</i> value
returned by <b>pgm_readpgminit()</b> is, however, not translated. It
represents the actual format of the PBM file.
<p><b>pgm_readpgminit()</b> reads the header of a PGM file, returning
all the information from the header and leaving the file positioned
just after the header.
<p><b>pgm_readpgmrow()</b> reads a row of grays into the <i>grayrow
</i> array. <i>format</i>, <i>cols</i>, and <i>maxval </i> are the
values returned by <b>pgm_readpgminit()</b>.
<p><b>pgm_readpgm()</b> reads an entire PGM image into memory,
returning the allocated array as its return value and returning the
information from the header as <i>rows</i>, <i>cols</i>, and
<i>maxval</i>. This function combines <b>pgm_readpgminit()</b>,
<b>pgm_allocarray()</b>, and <b>pgm_readpgmrow()</b>.
<p><b>pgm_readpgminit()</b> and <b>pgm_readpgm</b> abort the program with
a message to Standard Error if the PGM 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').
<h3 id="writing">WRITING FILES</h3>
<b>pgm_writepgminit()</b> writes the header for a PGM file and leaves
it positioned just after the header.
<p><i>forceplain</i> is a logical value that tells
<b>pgm_writepgminit() </b> to write a header for a plain PGM format
file, as opposed to a raw PGM format file.
<p><b>pgm_writepgmrow()</b> writes the row <i>grayrow</i> to a PGM
file. For meaningful results, <i>cols</i>, <i>maxval</i>, and
<i>forceplain</i> must be the same as was used with
<b>pgm_writepgminit()</b>.
<p><b>pgm_writepgm()</b> write the header and all data for a PGM
image. This function combines <b>pgm_writepgminit()</b> and
<b>pgm_writepgmrow()</b>.
<h3 id="miscellaneous">MISCELLANEOUS</h3>
<p><b>pgm_nextimage()</b> positions a PGM input file to the next image
in it (so that a subsequent <b>pgm_readpgminit()</b> reads its
header).
<p><b>pgm_nextimage()</b> is analogous to <b>pbm_nextimage()</b>, but
works on PGM and PBM files.
<p><b>pgm_check() </b> checks for the common file integrity error
where the file is the wrong size to contain all the image data.
<p><b>pgm_check() </b> is analogous to <b>pbm_check()</b>, but works
on PGM and PBM files.
<h2 id="seealso">SEE ALSO</h2>
<b><a href="libpbm.html">libpbm</a></b>,
<b><a href="libppm.html">libppm</a></b>,
<b><a href="libpnm.html">libpnm</a></b>
<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="#initialization">INITIALIZATION</a>
<li><a href="#memorymanagement">MEMORY MANAGEMENT</a>
<li><a href="#reading">READING FILES</a>
<li><a href="#writing">WRITING FILES</a>
<li><a href="#miscellaneous">MISCELLANEOUS</a>
</ul>
<li><a href="#seealso">SEE ALSO</a>
</ul>
</body>
</html>
|