From 22f36fb08bc15bda3630e405d5e214d5dc3bb497 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Wed, 26 Mar 2008 22:10:45 +0000 Subject: Fix -colorvalue, -saturation, -keephues options git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@605 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- editor/pnmnorm.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'editor') diff --git a/editor/pnmnorm.c b/editor/pnmnorm.c index 51d954a8..9048ee04 100644 --- a/editor/pnmnorm.c +++ b/editor/pnmnorm.c @@ -29,9 +29,10 @@ #include -#include "pnm.h" -#include "shhopt.h" +#include "pm_c_util.h" #include "mallocvar.h" +#include "shhopt.h" +#include "pnm.h" enum brightMethod {BRIGHT_LUMINOSITY, BRIGHT_COLORVALUE, BRIGHT_SATURATION}; @@ -60,8 +61,8 @@ struct cmdlineInfo { static void -parseCommandLine (int argc, char ** argv, - struct cmdlineInfo *cmdlineP) { +parseCommandLine(int argc, const char ** argv, + struct cmdlineInfo * const cmdlineP) { /*---------------------------------------------------------------------------- parse program command line described in Unix standard form by argc and argv. Return the information in the options as *cmdlineP. @@ -116,7 +117,7 @@ parseCommandLine (int argc, char ** argv, opt.short_allowed = FALSE; /* We have no short (old-fashioned) options */ opt.allowNegNum = FALSE; /* We have no parms that are negative numbers */ - optParseOptions3( &argc, argv, opt, sizeof(opt), 0 ); + optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0); /* Uses and sets argc, argv, and some of *cmdline_p and others. */ if (!cmdlineP->wpercentSpec) @@ -545,9 +546,9 @@ writeRowNormalized(xel * const xelrow, float const scaler = brightScaler(p, maxval, newBrightness, brightMethod); - xelval const r = MIN((int)(PPM_GETR(p)*scaler+0.5), maxval); - xelval const g = MIN((int)(PPM_GETG(p)*scaler+0.5), maxval); - xelval const b = MIN((int)(PPM_GETB(p)*scaler+0.5), maxval); + xelval const r = MIN(ROUNDU(PPM_GETR(p)*scaler), maxval); + xelval const g = MIN(ROUNDU(PPM_GETG(p)*scaler), maxval); + xelval const b = MIN(ROUNDU(PPM_GETB(p)*scaler), maxval); PNM_ASSIGN(outrow[col], r, g, b); } else PNM_ASSIGN(outrow[col], @@ -563,7 +564,7 @@ writeRowNormalized(xel * const xelrow, int -main(int argc, char *argv[]) { +main(int argc, const char *argv[]) { struct cmdlineInfo cmdline; FILE *ifP; @@ -572,7 +573,7 @@ main(int argc, char *argv[]) { int rows, cols, format; xelval bvalue, wvalue; - pnm_init(&argc, argv); + pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); @@ -608,7 +609,7 @@ main(int argc, char *argv[]) { for (row = 0; row < rows; ++row) { pnm_readpnmrow(ifP, xelrow, cols, maxval, format); writeRowNormalized(xelrow, cols, maxval, format, - cmdline.keephues, cmdline.brightMethod, + cmdline.brightMethod, cmdline.keephues, newBrightness, rowbuf); } free(newBrightness); -- cgit 1.4.1