Debian Codegraph @

converter/other/pamtopam.c

raw
1 /*=============================================================================
2 pamtopam
3 ===============================================================================
4 Part of the Netpbm package.
5
6 Copy PAM and PNM (i.e. PBM, PGM, or PPM) images from Standard Input
7 to Standard Output (while converting PNM images to PAM)
8
9 By Paul Bolle October 2007.
10
11 Contributed to the public domain by its author.
12 =============================================================================*/
13
14 #include "pm_c_util.h"
15 #include "pam.h"
16
17 int
18 main(int argc, const char * argv[]) {
19
20 int eof; /* no more images in input stream */
21 struct pam inpam; /* Input PAM image */
22 struct pam outpam; /* Output PAM image */
23
24 pm_proginit(&argc, argv);
25
26 if (argc-1 != 0)
27 pm_error("Program takes no arguments. Input is from Standard Input");
28
29 eof = FALSE;
30 while (!eof) {
31 pnm_readpaminit(stdin, &inpam, PAM_STRUCT_SIZE(tuple_type));
32
33 outpam = inpam;
34 outpam.file = stdout;
35 outpam.format = PAM_FORMAT;
36
37 pnm_writepaminit(&outpam);
38
39 {
40 tuple * tuplerow;
41
42 tuplerow = pnm_allocpamrow(&inpam);
43 {
44 unsigned int row;
45
46 for (row = 0; row < inpam.height; ++row) {
47 pnm_readpamrow(&inpam, tuplerow);
48 pnm_writepamrow(&outpam, tuplerow);
49 }
50 }
51 pnm_freepamrow(tuplerow);
52 }
53 pnm_nextimage(stdin, &eof);
54 }
55
56 return 0;
57 }
58
59
60