blob: d1a88fd64c46523c079bd4b199b6efb3dd71d5c6 (
plain) (
blame)
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
|
/*----------------------------------------------------------------------------
pamtopam
------------------------------------------------------------------------------
Part of the Netpbm package.
Copy PAM and PNM (i.e. PBM, PGM, or PPM) images from Standard Input
to Standard Output (while converting PNM images to PAM)
-----------------------------------------------------------------------------*/
#include "pm_c_util.h"
#include "pam.h"
int
main(int argc, char *argv[]) {
bool eof; /* no more images in input stream */
struct pam inpam; /* Input PAM image */
struct pam outpam; /* Output PAM image */
pm_proginit(&argc, argv);
if (argc-1 != 0)
pm_error("Program takes no arguments. Input is from Standard Input");
eof = FALSE;
while (!eof) {
pnm_readpaminit(stdin, &inpam, PAM_STRUCT_SIZE(tuple_type));
outpam = inpam;
outpam.file = stdout;
outpam.format = PAM_FORMAT;
pnm_writepaminit(&outpam);
{
tuple * tuplerow;
tuplerow = pnm_allocpamrow(&inpam);
{
unsigned int row;
for (row = 0; row < inpam.height; ++row) {
pnm_readpamrow(&inpam, tuplerow);
pnm_writepamrow(&outpam, tuplerow);
}
}
pnm_freepamrow(tuplerow);
}
pnm_nextimage(stdin, &eof);
}
return 0;
}
|