From 26092f5e2264b80706f4a980a9e79a8289254103 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 29 Dec 2019 16:04:24 +0000 Subject: Promote Development to Advanced as 10.89.00 git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@3723 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- analyzer/pamfind.c | 2 +- converter/other/pamtopng.c | 2 +- doc/HISTORY | 16 +++++-- editor/pamrubber.c | 104 ++++++++++++++++++++++----------------------- editor/pnmpad.c | 40 +++++++++++++---- editor/pnmquant | 23 ++++++++-- test/pgmhist.test | 2 +- test/pnmquant.test | 2 +- version.mk | 4 +- 9 files changed, 121 insertions(+), 74 deletions(-) diff --git a/analyzer/pamfind.c b/analyzer/pamfind.c index acfb5ded..15ca9e85 100644 --- a/analyzer/pamfind.c +++ b/analyzer/pamfind.c @@ -125,7 +125,7 @@ targetValue(CmdLineInfo const cmdLine, } else { if (cmdLine.targetDepth != inpamP->depth) pm_error("You specified a %u-tuple for -target, " - "but the input image of of depth %u", + "but the input image is of depth %u", cmdLine.targetDepth, inpamP->depth); else { unsigned int i; diff --git a/converter/other/pamtopng.c b/converter/other/pamtopng.c index 68d4055d..cfff38cb 100644 --- a/converter/other/pamtopng.c +++ b/converter/other/pamtopng.c @@ -251,7 +251,7 @@ colorTypeFromInputType(const struct pam * const pamP) { -----------------------------------------------------------------------------*/ png_byte retval; - if (pamP->depth < 1 && pamP->depth > 4) + if (pamP->depth < 1 || pamP->depth > 4) pm_error ("Number of color planes must be between 1 and 4 inclusive"); if (pamP->maxval != 1 && pamP->maxval != 3 && pamP->maxval != 15 && diff --git a/doc/HISTORY b/doc/HISTORY index 66fa9cbe..75c84d7c 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -4,16 +4,24 @@ Netpbm. CHANGE HISTORY -------------- -19.12.25 BJH Release 10.88.02 - pamrubber: Fix bug: -frame doesn't work. Always broken. - (Pamrubber was new in Netpbm 10.54 (March 2011). -19.12.03 BJH Release 10.88.01 +19.12.29 BJH Release 10.89.00 + + pnmpad: Add -reportonly. anytopnm: Fix unpredictable behavior when file name contains spaces. + pamfind: Fix typo in message. + + pnmquant: Fail if user specifies both -spreadbrightness and + -spreadluminosity or both -randomseed and -norandom, rather + than just pick one. + + pamrubber: Fix bug: -frame doesn't work. Always broken. + (Pamrubber was new in Netpbm 10.54 (March 2011). + 19.09.28 BJH Release 10.88.00 pnmquant: Fail if user specifies more than one of -meanpixel, diff --git a/editor/pamrubber.c b/editor/pamrubber.c index a5748104..602701ec 100644 --- a/editor/pamrubber.c +++ b/editor/pamrubber.c @@ -83,7 +83,7 @@ parseCmdline(int argc, const char ** argv, /* instructions to optParseOptions3 on how to parse our options. */ optEntry * option_def; optStruct3 opt; - + MALLOCARRAY_NOFAIL(option_def, 100); option_def_index = 0; /* incremented by OPTENT3 */ @@ -268,7 +268,7 @@ maketriangle(point const p1, retval.p1 = p1; retval.p2 = p2; retval.p3 = p3; - + return retval; } @@ -382,11 +382,11 @@ sideTriangleVerticalEdge(unsigned int const n, point const p24, point const r21, point const r22) { - + if (((n >= 4) && (r11.x < p11.x) && (p14.x < p13.x) && (p14.x < p12.x) && (p14.x < p11.x)) /* left edge */ - || + || ((n >= 4) && (r11.x > p11.x) && (p14.x > p13.x) && (p14.x > p12.x) && (p14.x > p11.x))) /* right edge */ { @@ -394,7 +394,7 @@ sideTriangleVerticalEdge(unsigned int const n, *trig2P = maketriangle(r21, r22, p24); } else if (((n >= 3) && (r11.x < p11.x) && (p13.x < p12.x) && (p13.x < p11.x)) /* left edge */ - || + || ((n >= 3) && (r11.x > p11.x) && (p13.x > p12.x) && (p13.x > p11.x))) /* right edge */ { *trig1P = maketriangle(r11, r12, p13); @@ -403,7 +403,7 @@ sideTriangleVerticalEdge(unsigned int const n, && (p12.x < p11.x)) /* left edge */ || ((n >= 2) && (r11.x > p11.x) - && (p12.x > p11.x))) /* right edge */ { + && (p12.x > p11.x))) /* right edge */ { *trig1P = maketriangle(r11, r12, p12); *trig2P = maketriangle(r21, r22, p22); } else if (n >= 1) { @@ -430,24 +430,24 @@ sideTriangleHorizontalEdge(unsigned int const n, point const p24, point const r21, point const r22) { - + if (((n >= 4) && (r11.y < p11.y) && (p14.y < p13.y) && (p14.y < p12.y) && (p14.y < p11.y)) /* top edge */ - || + || ((n >= 4) && (r11.y > p11.y) && (p14.y > p13.y) && (p14.y > p12.y) && (p14.y > p11.y))) /* bottom edge */ { *trig1P = maketriangle(r11, r12, p14); *trig2P = maketriangle(r21, r22, p24); } else if (((n >= 3) && (r11.y < p11.y) && (p13.y < p12.y) && (p13.y < p11.y)) /* top edge */ - || + || ((n >= 3) && (r11.y > p11.y) && (p13.y > p12.y) && (p13.y > p11.y))) /* bottom edge */ { *trig1P = maketriangle(r11, r12, p13); *trig2P = maketriangle(r21, r22, p23); } else if (((n >= 2) && (r11.y < p11.y) && (p12.y < p11.y)) /* top edge */ - || + || ((n >= 2) && (r11.y > p11.y) && (p12.y > p11.y))) /* bottom edge */ { *trig1P = maketriangle(r11, r12, p12); @@ -505,7 +505,7 @@ edgeTriangle(triangle * const trig1P, point const tr2, point const bl2, point const br2) { - + if ((p11.x < p12.x) && (p11.y < p12.y)) { /* up/left to down/right */ *trig1P = maketriangle(tr1, p12, p11); @@ -633,7 +633,7 @@ frameDrawproc (tuple ** const tuples, sample const maxval, pamd_point const p, const void * const clientdata) { - + int yy; for (yy = p.y - 1; yy <= p.y + 1; ++yy) { @@ -688,14 +688,14 @@ clippedPoint(const struct pam * const pamP, clippedX = pamP->width - 2; else clippedX = roundedX; - + if (roundedY <= 0) clippedY = 1; else if (roundedY > pamP->height - 1) clippedY = pamP->height - 2; else clippedY = roundedY; - + return pamd_makePoint(clippedX, clippedY); } @@ -749,19 +749,19 @@ prepTrig(int const wd, /* connect control point to all corners to get 4 triangles */ /* left side triangle */ sideTriangle(nCP, - &tri1s[0], c1p1, p0, p0, p0, rbl1, rtl1, + &tri1s[0], c1p1, p0, p0, p0, rbl1, rtl1, &tri2s[0], c2p1, p0, p0, p0, rbl2, rtl2); /* top side triangle */ sideTriangle(nCP, - &tri1s[1], c1p1, p0, p0, p0, rtl1, rtr1, + &tri1s[1], c1p1, p0, p0, p0, rtl1, rtr1, &tri2s[1], c2p1, p0, p0, p0, rtl2, rtr2); /* right side triangle */ sideTriangle(nCP, - &tri1s[2], c1p1, p0, p0, p0, rtr1, rbr1, + &tri1s[2], c1p1, p0, p0, p0, rtr1, rbr1, &tri2s[2], c2p1, p0, p0, p0, rtr2, rbr2); /* bottom side triangle */ sideTriangle(nCP, - &tri1s[3], c1p1, p0, p0, p0, rbr1, rbl1, + &tri1s[3], c1p1, p0, p0, p0, rbr1, rbl1, &tri2s[3], c2p1, p0, p0, p0, rbr2, rbl2); nTri = 4; @@ -778,19 +778,19 @@ prepTrig(int const wd, /* connect two control points to corners to get 6 triangles */ /* left side */ sideTriangle(nCP, - &tri1s[0], c1p1, c1p2, p0, p0, rbl1, rtl1, + &tri1s[0], c1p1, c1p2, p0, p0, rbl1, rtl1, &tri2s[0], c2p1, c2p2, p0, p0, rbl2, rtl2); /* top side */ - sideTriangle(nCP, - &tri1s[1], c1p1, c1p2, p0, p0, rtl1, rtr1, + sideTriangle(nCP, + &tri1s[1], c1p1, c1p2, p0, p0, rtl1, rtr1, &tri2s[1], c2p1, c2p2, p0, p0, rtl2, rtr2); /* right side */ - sideTriangle(nCP, - &tri1s[2], c1p1, c1p2, p0, p0, rtr1, rbr1, + sideTriangle(nCP, + &tri1s[2], c1p1, c1p2, p0, p0, rtr1, rbr1, &tri2s[2], c2p1, c2p2, p0, p0, rtr2, rbr2); /* bottom side */ - sideTriangle(nCP, - &tri1s[3], c1p1, c1p2, p0, p0, rbr1, rbl1, + sideTriangle(nCP, + &tri1s[3], c1p1, c1p2, p0, p0, rbr1, rbl1, &tri2s[3], c2p1, c2p2, p0, p0, rbr2, rbl2); /* edge to corner triangles */ @@ -803,7 +803,7 @@ prepTrig(int const wd, c1p1 = oldCP[0]; c1p2 = oldCP[1]; c1p3 = oldCP[2]; - + c2p1 = newCP[0]; c2p2 = newCP[1]; c2p3 = newCP[2]; @@ -828,7 +828,7 @@ prepTrig(int const wd, c1p1 = tri1s[0].p1; c1p2 = tri1s[0].p2; c1p3 = tri1s[0].p3; - + c2p1 = tri2s[0].p1; c2p2 = tri2s[0].p2; c2p3 = tri2s[0].p3; @@ -836,19 +836,19 @@ prepTrig(int const wd, /* point to side triangles */ /* left side */ sideTriangle(nCP, - &tri1s[1], c1p1, c1p2, c1p3, p0, rbl1, rtl1, + &tri1s[1], c1p1, c1p2, c1p3, p0, rbl1, rtl1, &tri2s[1], c2p1, c2p2, c2p3, p0, rbl2, rtl2); /* top side */ - sideTriangle(nCP, - &tri1s[2], c1p1, c1p2, c1p3, p0, rtl1, rtr1, + sideTriangle(nCP, + &tri1s[2], c1p1, c1p2, c1p3, p0, rtl1, rtr1, &tri2s[2], c2p1, c2p2, c2p3, p0, rtl2, rtr2); /* right side */ - sideTriangle(nCP, - &tri1s[3], c1p1, c1p2, c1p3, p0, rtr1, rbr1, + sideTriangle(nCP, + &tri1s[3], c1p1, c1p2, c1p3, p0, rtr1, rbr1, &tri2s[3], c2p1, c2p2, c2p3, p0, rtr2, rbr2); /* bottom side */ - sideTriangle(nCP, - &tri1s[4], c1p1, c1p2, c1p3, p0, rbr1, rbl1, + sideTriangle(nCP, + &tri1s[4], c1p1, c1p2, c1p3, p0, rbr1, rbl1, &tri2s[4], c2p1, c2p2, c2p3, p0, rbr2, rbl2); /* edge to corner triangles */ @@ -864,7 +864,7 @@ prepTrig(int const wd, c1p2 = oldCP[1]; c1p3 = oldCP[2]; c1p4 = oldCP[3]; - + c2p1 = newCP[0]; c2p2 = newCP[1]; c2p3 = newCP[2]; @@ -945,20 +945,20 @@ prepTrig(int const wd, /* triangle from triangle point to side of image */ /* left side triangle */ - sideTriangle(nCP, - &tri1s[2], c1p1, c1p2, c1p3, c1p4, rbl1, rtl1, + sideTriangle(nCP, + &tri1s[2], c1p1, c1p2, c1p3, c1p4, rbl1, rtl1, &tri2s[2], c2p1, c2p2, c2p3, c2p4, rbl2, rtl2); /* top side triangle */ - sideTriangle(nCP, - &tri1s[3], c1p1, c1p2, c1p3, c1p4, rtl1, rtr1, + sideTriangle(nCP, + &tri1s[3], c1p1, c1p2, c1p3, c1p4, rtl1, rtr1, &tri2s[3], c2p1, c2p2, c2p3, c2p4, rtl2, rtr2); /* right side triangle */ - sideTriangle(nCP, - &tri1s[4], c1p1, c1p2, c1p3, c1p4, rtr1, rbr1, + sideTriangle(nCP, + &tri1s[4], c1p1, c1p2, c1p3, c1p4, rtr1, rbr1, &tri2s[4], c2p1, c2p2, c2p3, c2p4, rtr2, rbr2); /* bottom side triangle */ - sideTriangle(nCP, - &tri1s[5], c1p1, c1p2, c1p3, c1p4, rbr1, rbl1, + sideTriangle(nCP, + &tri1s[5], c1p1, c1p2, c1p3, c1p4, rbr1, rbl1, &tri2s[5], c2p1, c2p2, c2p3, c2p4, rbr2, rbl2); /*-------------------------------------------------------------------*/ @@ -1014,7 +1014,7 @@ prepQuad(void) { /* bottom-right and top-left */ quad1 = quadRect(oldCP[1].x, oldCP[0].x, oldCP[1].y, oldCP[0].y); } - + if ((newCP[0].x < newCP[1].x) && (newCP[0].y < newCP[1].y)) { /* top-left and bottom-right */ quad2 = quadRect(newCP[0].x, newCP[1].x, newCP[0].y, newCP[1].y); @@ -1034,7 +1034,7 @@ prepQuad(void) { /* diagonal of the parallelogram is the two control points furthest apart */ - + d01 = distance(newCP[0], newCP[1]); d12 = distance(newCP[1], newCP[2]); d20 = distance(newCP[2], newCP[0]); @@ -1163,7 +1163,7 @@ warpTrig(point const p2, /* map target control points to source control points */ e1p1.x = tri1s[i].p2.x - + (e2p1.x - tri2s[i].p2.x)/(tri2s[i].p3.x - tri2s[i].p2.x) + + (e2p1.x - tri2s[i].p2.x)/(tri2s[i].p3.x - tri2s[i].p2.x) * (tri1s[i].p3.x - tri1s[i].p2.x); e1p1.y = tri1s[i].p2.y + (e2p1.y - tri2s[i].p2.y)/(tri2s[i].p3.y - tri2s[i].p2.y) @@ -1215,7 +1215,7 @@ warpQuad(point const p2, c1tr = quad1.tr; c1bl = quad1.bl; c1br = quad1.br; - + c2tl = quad2.tl; c2tr = quad2.tr; c2bl = quad2.bl; @@ -1364,22 +1364,22 @@ pix(tuple ** const tuples, pix = 0.0; if (((int) floor(p.x) >= 0) && ((int) floor(p.x) < width) && ((int) floor(p.y) >= 0) && ((int) floor(p.y) < height)) { - pix += (1.0 - rx) * (1.0 - ry) + pix += (1.0 - rx) * (1.0 - ry) * tuples[(int) floor(p.y)][(int) floor(p.x)][plane]; } if (((int) floor(p.x) + 1 >= 0) && ((int) floor(p.x) + 1 < width) && ((int) floor(p.y) >= 0) && ((int) floor(p.y) < height)) { - pix += rx * (1.0 - ry) + pix += rx * (1.0 - ry) * tuples[(int) floor(p.y)][(int) floor(p.x) + 1][plane]; } if (((int) floor(p.x) >= 0) && ((int) floor(p.x) < width) && ((int) floor(p.y) + 1 >= 0) && ((int) floor(p.y) + 1 < height)) { - pix += (1.0 - rx) * ry + pix += (1.0 - rx) * ry * tuples[(int) floor(p.y) + 1][(int) floor(p.x)][plane]; } if (((int) floor(p.x) + 1 >= 0) && ((int) floor(p.x) + 1 < width) && ((int) floor(p.y) + 1 >= 0) && ((int) floor(p.y) + 1 < height)) { - pix += rx * ry + pix += rx * ry * tuples[(int) floor(p.y) + 1][(int) floor(p.x) + 1][plane]; } } @@ -1398,7 +1398,7 @@ main(int argc, const char ** const argv) { tuple ** inTuples; tuple ** outTuples; unsigned int p2y; - + pm_proginit(&argc, argv); parseCmdline(argc, argv, &cmdline); diff --git a/editor/pnmpad.c b/editor/pnmpad.c index 9c7a77e5..55cdcd6c 100644 --- a/editor/pnmpad.c +++ b/editor/pnmpad.c @@ -38,6 +38,7 @@ struct cmdlineInfo { unsigned int mwidth; unsigned int mheight; unsigned int white; /* >0: pad white; 0: pad black */ + unsigned int reportonly; unsigned int verbose; }; @@ -86,14 +87,16 @@ parseCommandLine(int argc, const char ** argv, &yalignSpec, 0); OPTENT3(0, "valign", OPT_FLOAT, &cmdlineP->yalign, &yalignSpec, 0); - OPTENT3(0, "black", OPT_FLAG, NULL, - &blackOpt, 0); OPTENT3(0, "mwidth", OPT_UINT, &cmdlineP->mwidth, &mwidthSpec, 0); OPTENT3(0, "mheight", OPT_UINT, &cmdlineP->mheight, &mheightSpec, 0); + OPTENT3(0, "black", OPT_FLAG, NULL, + &blackOpt, 0); OPTENT3(0, "white", OPT_FLAG, NULL, &cmdlineP->white, 0); + OPTENT3(0, "reportonly", OPT_FLAG, NULL, + &cmdlineP->reportonly, 0); OPTENT3(0, "verbose", OPT_FLAG, NULL, &cmdlineP->verbose, 0); @@ -488,6 +491,23 @@ computePadSizes(struct cmdlineInfo const cmdline, +static void +reportPadSizes(int const inCols, + int const inRows, + unsigned int const lpad, + unsigned int const rpad, + unsigned int const tpad, + unsigned int const bpad) { + + unsigned int const outCols = inCols + lpad + rpad; + unsigned int const outRows = inRows + tpad + bpad; + + printf("%u %u %u %u %u %u\n", lpad, rpad, tpad, bpad, outCols, outRows); + +} + + + static void padPbm(FILE * const ifP, unsigned int const cols, @@ -636,12 +656,16 @@ main(int argc, const char ** argv) { newcols = cols + lpad + rpad; - if (PNM_FORMAT_TYPE(format) == PBM_TYPE) - padPbm(ifP, cols, rows, format, newcols, lpad, rpad, tpad, bpad, - !!cmdline.white); - else - padGeneral(ifP, cols, rows, maxval, format, - newcols, lpad, rpad, tpad, bpad, !!cmdline.white); + if (cmdline.reportonly) + reportPadSizes(cols, rows, lpad, rpad, tpad, bpad); + else { + if (PNM_FORMAT_TYPE(format) == PBM_TYPE) + padPbm(ifP, cols, rows, format, newcols, lpad, rpad, tpad, bpad, + !!cmdline.white); + else + padGeneral(ifP, cols, rows, maxval, format, + newcols, lpad, rpad, tpad, bpad, !!cmdline.white); + } pm_close(ifP); diff --git a/editor/pnmquant b/editor/pnmquant index 80d8e09f..f7af9e7a 100755 --- a/editor/pnmquant +++ b/editor/pnmquant @@ -89,7 +89,7 @@ sub parseCommandLine(@) { my %cmdline; - my $validOptions = GetOptions(\%cmdline, + my $optsAreValid = GetOptions(\%cmdline, "center", "meancolor", "meanpixel", @@ -101,7 +101,7 @@ sub parseCommandLine(@) { "quiet", "plain"); - if (!$validOptions) { + if (!$optsAreValid) { print(STDERR "Invalid option syntax.\n"); exit(1); } @@ -199,10 +199,10 @@ sub openSeekableAsStdin($) { -sub makeColormap($$$$$$) { +sub makeColormap($$$$$$$) { my ($ncolors, $opt_center, $opt_meanpixel, $opt_meancolor, - $opt_spreadluminosity, $opt_quiet) = @_; + $opt_spreadbrightness, $opt_spreadluminosity, $opt_quiet) = @_; # Make a colormap of $ncolors colors from the image on Standard Input. # Put it in a temporary file and return its name. @@ -235,6 +235,16 @@ sub makeColormap($$$$$$) { $averageOpt = "-center"; } + my $spreadOptCt = + (defined($opt_spreadluminosity) ? 1 : 0) + + (defined($opt_spreadbrightness) ? 1 : 0); + + if ($spreadOptCt > 1) { + print(STDERR "You can specify only one of " . + "-spreadluminosity and -spreadbrightness\n"); + exit(1); + } + my $spreadOpt; if (defined($opt_spreadluminosity)) { $spreadOpt = "-spreadluminosity"; @@ -276,6 +286,10 @@ sub remap($$$$$$) { push(@options, "-floyd"); } if ($opt_norandom) { + if (defined($opt_randomseed)) { + print(STDERR "You cannot specify -randomseed with -norandom\n"); + exit(1); + } push(@options, "-norandom"); } if (defined($opt_randomseed)) { @@ -322,6 +336,7 @@ my $mapfileSpec = makeColormap($cmdlineR->{ncolors}, $cmdlineR->{center}, $cmdlineR->{meanpixel}, $cmdlineR->{meancolor}, + $cmdlineR->{spreadbrightness}, $cmdlineR->{spreadluminosity}, $cmdlineR->{quiet}); diff --git a/test/pgmhist.test b/test/pgmhist.test index 3be74898..ab3763fd 100755 --- a/test/pgmhist.test +++ b/test/pgmhist.test @@ -34,7 +34,7 @@ echo "Invalid command-line argument combinations." 1>&2 echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 -pgmhist -median -quartile testgrid.pbm > ${test_out} || \ +pgmhist -median -quartile testgrid.pbm > ${test_out} || \ echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? pgmhist -median -decile testgrid.pbm > ${test_out} || \ echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? diff --git a/test/pnmquant.test b/test/pnmquant.test index 1154cf84..3a2ef906 100755 --- a/test/pnmquant.test +++ b/test/pnmquant.test @@ -55,7 +55,7 @@ pnmquant -meancolor -meanpixel 16 testimg.ppm > ${test_out} || \ echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? pnmquant -spreadbrightness -spreadluminosity 16 testimg.ppm > ${test_out} || \ echo -n "Expected failure 7"; test -s ${test_out}; echo " "$? -pnmquant -floyd -nofloyd 16 testimg.ppm > ${test_out} || \ +pnmquant -randomseed 1 -norandom 10 testimg.ppm > ${test_out} || \ echo -n "Expected failure 8"; test -s ${test_out}; echo " "$? rm ${test_out} diff --git a/version.mk b/version.mk index 1fd245ab..97d8b3c7 100644 --- a/version.mk +++ b/version.mk @@ -1,3 +1,3 @@ NETPBM_MAJOR_RELEASE = 10 -NETPBM_MINOR_RELEASE = 88 -NETPBM_POINT_RELEASE = 2 +NETPBM_MINOR_RELEASE = 89 +NETPBM_POINT_RELEASE = 0 -- cgit 1.4.1