diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-12-02 17:14:38 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-12-02 17:14:38 +0000 |
commit | 4dd3bf19f65a5d3d414a5fe8b2387bd02b1d535b (patch) | |
tree | a41581f119a56e6b960b6bc6060386439f48a711 /converter | |
parent | 72cab9afab6e82ff2ded34bff0c897f92ce9ff0a (diff) | |
download | netpbm-mirror-4dd3bf19f65a5d3d414a5fe8b2387bd02b1d535b.tar.gz netpbm-mirror-4dd3bf19f65a5d3d414a5fe8b2387bd02b1d535b.tar.xz netpbm-mirror-4dd3bf19f65a5d3d414a5fe8b2387bd02b1d535b.zip |
Make pamtopnm work on multi-image stream
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@161 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter')
-rw-r--r-- | converter/other/pamtopnm.c | 59 |
1 files changed, 33 insertions, 26 deletions
diff --git a/converter/other/pamtopnm.c b/converter/other/pamtopnm.c index cc1164da..6835b43f 100644 --- a/converter/other/pamtopnm.c +++ b/converter/other/pamtopnm.c @@ -108,6 +108,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 +118,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; } |