diff options
Diffstat (limited to 'converter/other/pamtopnm.c')
-rw-r--r-- | converter/other/pamtopnm.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/converter/other/pamtopnm.c b/converter/other/pamtopnm.c index f0ad451a..45ab1beb 100644 --- a/converter/other/pamtopnm.c +++ b/converter/other/pamtopnm.c @@ -33,9 +33,7 @@ parseCommandLine(int argc, const char ** argv, Note that the file spec array we return is stored in the storage that was passed to us as the argv array. -----------------------------------------------------------------------------*/ - optEntry * option_def; - /* Instructions to OptParseOptions3 on how to parse our options. - */ + optEntry * option_def; /* Used by OPTENT3 */ optStruct3 opt; unsigned int option_def_index; @@ -49,10 +47,10 @@ parseCommandLine(int argc, const char ** argv, opt.short_allowed = FALSE; /* We have no short (old-fashioned) options */ opt.allowNegNum = FALSE; /* We have no parms that are negative numbers */ - pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0); + pm_optParseOptions4(&argc, argv, opt, sizeof(opt), 0); /* Uses and sets argc, argv, and some of *cmdlineP and others. */ - if (argc-1 == 0) + if (argc-1 == 0) cmdlineP->inputFileName = "-"; else if (argc-1 != 1) pm_error("Program takes zero or one argument (filename). You " @@ -66,7 +64,7 @@ parseCommandLine(int argc, const char ** argv, static void -validateTupleType(struct pam const inpam, +validateTupleType(struct pam const inpam, int const assumeTupleType) { /*---------------------------------------------------------------------------- Make sure the image has a tuple type we know how to convert to PNM. @@ -83,18 +81,18 @@ validateTupleType(struct pam const inpam, if (assumeTupleType) { /* User says tuple type is appropriate regardless of tuple_type. */ } else { - if (inpam.depth >= 1 && - strncmp(inpam.tuple_type, "BLACKANDWHITE", + if (inpam.depth >= 1 && + strncmp(inpam.tuple_type, "BLACKANDWHITE", sizeof("BLACKANDWHITE")-1) == 0) { /* It's a PBMable image */ - } else if (inpam.depth >= 1 && + } else if (inpam.depth >= 1 && strncmp(inpam.tuple_type, "GRAYSCALE", sizeof("GRAYSCALE")-1) == 0) { /* It's a PGMable image */ } else if (inpam.depth >= 3 && strncmp(inpam.tuple_type, "RGB", sizeof("RGB")-1) == 0) { /* It's a PPMable image */ - } else + } else pm_error("PAM image does not have a depth and tuple_type " "consistent with a PNM image. " "According to its " @@ -129,12 +127,12 @@ main(int argc, const char **argv) { outpam = inpam; outpam.file = stdout; - + if (inpam.depth < 3) { outpam.depth = 1; if (inpam.maxval == 1) outpam.format = PBM_FORMAT; - else + else outpam.format = PGM_FORMAT; } else { outpam.depth = 3; @@ -145,17 +143,17 @@ main(int argc, const char **argv) { { tuple *tuplerow; - - tuplerow = pnm_allocpamrow(&inpam); - { + + 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); @@ -163,3 +161,6 @@ main(int argc, const char **argv) { return 0; } + + + |