diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2016-03-27 01:38:28 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2016-03-27 01:38:28 +0000 |
commit | 367c9cb514c9da766488b9bdb218a18e31cb7624 (patch) | |
tree | f9e343be94161a4837f0f1c1d072a35538ae0f63 /converter/other/pamtopnm.c | |
parent | 6e88e3326cb0c7f7975b56189278cab3f84ba1bd (diff) | |
download | netpbm-mirror-367c9cb514c9da766488b9bdb218a18e31cb7624.tar.gz netpbm-mirror-367c9cb514c9da766488b9bdb218a18e31cb7624.tar.xz netpbm-mirror-367c9cb514c9da766488b9bdb218a18e31cb7624.zip |
Promote Stable (10.47) to Super Stable
git-svn-id: http://svn.code.sf.net/p/netpbm/code/super_stable@2691 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other/pamtopnm.c')
-rw-r--r-- | converter/other/pamtopnm.c | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/converter/other/pamtopnm.c b/converter/other/pamtopnm.c index cc1164da..86f6514c 100644 --- a/converter/other/pamtopnm.c +++ b/converter/other/pamtopnm.c @@ -12,6 +12,7 @@ #include <string.h> +#include "pm_c_util.h" #include "pam.h" #include "shhopt.h" #include "mallocvar.h" @@ -108,6 +109,7 @@ main(int argc, char *argv[]) { struct cmdlineInfo cmdline; FILE* ifP; + bool eof; /* no more images in input stream */ struct pam inpam; /* Input PAM image */ struct pam outpam; /* Output PNM image */ @@ -117,39 +119,45 @@ main(int argc, char *argv[]) { ifP = pm_openr(cmdline.inputFilespec); - pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type)); + eof = FALSE; + while (!eof) { + pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type)); - validateTupleType(inpam, cmdline.assume); + validateTupleType(inpam, cmdline.assume); - outpam = inpam; - outpam.file = stdout; - - if (inpam.depth < 3) { - outpam.depth = 1; - if (inpam.maxval == 1) - outpam.format = PBM_FORMAT; - else - outpam.format = PGM_FORMAT; - } else { - outpam.depth = 3; - outpam.format = PPM_FORMAT; - } + outpam = inpam; + outpam.file = stdout; + + if (inpam.depth < 3) { + outpam.depth = 1; + if (inpam.maxval == 1) + outpam.format = PBM_FORMAT; + else + outpam.format = PGM_FORMAT; + } else { + outpam.depth = 3; + outpam.format = PPM_FORMAT; + } - pnm_writepaminit(&outpam); + pnm_writepaminit(&outpam); - { - tuple *tuplerow; - - tuplerow = pnm_allocpamrow(&inpam); - { - int row; + { + tuple *tuplerow; - for (row = 0; row < inpam.height; row++) { - pnm_readpamrow(&inpam, tuplerow); - pnm_writepamrow(&outpam, tuplerow); + tuplerow = pnm_allocpamrow(&inpam); + { + int row; + + for (row = 0; row < inpam.height; row++) { + pnm_readpamrow(&inpam, tuplerow); + pnm_writepamrow(&outpam, tuplerow); + } } + pnm_freepamrow(tuplerow); } - pnm_freepamrow(tuplerow); + + pnm_nextimage(ifP, &eof); } + return 0; } |