diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-06-28 21:02:17 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-06-28 21:02:17 +0000 |
commit | d2b19d2aac20aeef5b213ffb0163610cde5d040b (patch) | |
tree | 109418bd080f35ef2eed8d1136c9700460ca30dd /converter/other | |
parent | aba8428cb76de567abd4ffda1c3280f970d0692c (diff) | |
download | netpbm-mirror-d2b19d2aac20aeef5b213ffb0163610cde5d040b.tar.gz netpbm-mirror-d2b19d2aac20aeef5b213ffb0163610cde5d040b.tar.xz netpbm-mirror-d2b19d2aac20aeef5b213ffb0163610cde5d040b.zip |
Release 10.47.73
git-svn-id: http://svn.code.sf.net/p/netpbm/code/super_stable@3634 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other')
-rw-r--r-- | converter/other/pnmtopng.c | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/converter/other/pnmtopng.c b/converter/other/pnmtopng.c index 7d30b23b..76c7a3a4 100644 --- a/converter/other/pnmtopng.c +++ b/converter/other/pnmtopng.c @@ -152,6 +152,7 @@ struct cmdlineInfo { unsigned int modtimeSpec; time_t modtime; /* Meaningless if !modtimeSpec */ const char * palette; /* NULL if none */ + bool filterSetSpec; int filterSet; unsigned int force; unsigned int libversion; @@ -424,15 +425,17 @@ parseCommandLine(int argc, char ** argv, if (!paletteSpec) cmdlineP->palette = NULL; - if (filterSpec + nofilter + sub + up + avg + paeth > 1) - pm_error("You may specify at most one of " - "-nofilter, -sub, -up, -avg, -paeth, and -filter"); + if (filterSpec && (nofilter + sub + up + avg + paeth > 0)) + pm_error("You may mot specify -filter with " + "-nofilter, -sub, -up, -avg, or -paeth"); if (filterSpec) { if (filter < 0 || filter > 4) pm_error("-filter is obsolete. Use -nofilter, -sub, -up, -avg, " "and -paeth options instead."); - else + else { + cmdlineP->filterSetSpec = true; + switch (filter) { case 0: cmdlineP->filterSet = PNG_FILTER_NONE; break; case 1: cmdlineP->filterSet = PNG_FILTER_SUB; break; @@ -440,21 +443,26 @@ parseCommandLine(int argc, char ** argv, case 3: cmdlineP->filterSet = PNG_FILTER_AVG; break; case 4: cmdlineP->filterSet = PNG_FILTER_PAETH; break; } + } } else { - if (nofilter) - cmdlineP->filterSet = PNG_FILTER_NONE; - else if (sub) - cmdlineP->filterSet = PNG_FILTER_SUB; - else if (up) - cmdlineP->filterSet = PNG_FILTER_UP; - else if (avg) - cmdlineP->filterSet = PNG_FILTER_AVG; - else if (paeth) - cmdlineP->filterSet = PNG_FILTER_PAETH; - else - cmdlineP->filterSet = PNG_FILTER_NONE; + if (nofilter + sub + up + avg + paeth == 0) + cmdlineP->filterSetSpec = false; + else { + cmdlineP->filterSetSpec = true; + cmdlineP->filterSet = PNG_NO_FILTERS; /* initial value */ + if (nofilter) + cmdlineP->filterSet |= PNG_FILTER_NONE; + if (sub) + cmdlineP->filterSet |= PNG_FILTER_SUB; + if (up) + cmdlineP->filterSet |= PNG_FILTER_UP; + if (avg) + cmdlineP->filterSet |= PNG_FILTER_AVG; + if (paeth) + cmdlineP->filterSet |= PNG_FILTER_PAETH; + } } - + if (cmdlineP->sizeSpec) parseSizeOpt(size, &cmdlineP->size); @@ -2739,6 +2747,9 @@ convertpnm(struct cmdlineInfo const cmdline, doTimeChunk(cmdline, info_ptr); + if (cmdline.filterSetSpec) + png_set_filter(png_ptr, 0, cmdline.filterSet); + if (cmdline.filterSet != 0) png_set_filter(png_ptr, 0, cmdline.filterSet); |