diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2016-03-27 01:38:28 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2016-03-27 01:38:28 +0000 |
commit | 367c9cb514c9da766488b9bdb218a18e31cb7624 (patch) | |
tree | f9e343be94161a4837f0f1c1d072a35538ae0f63 /editor/specialty/pgmbentley.c | |
parent | 6e88e3326cb0c7f7975b56189278cab3f84ba1bd (diff) | |
download | netpbm-mirror-367c9cb514c9da766488b9bdb218a18e31cb7624.tar.gz netpbm-mirror-367c9cb514c9da766488b9bdb218a18e31cb7624.tar.xz netpbm-mirror-367c9cb514c9da766488b9bdb218a18e31cb7624.zip |
Promote Stable (10.47) to Super Stable
git-svn-id: http://svn.code.sf.net/p/netpbm/code/super_stable@2691 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor/specialty/pgmbentley.c')
-rw-r--r-- | editor/specialty/pgmbentley.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/editor/specialty/pgmbentley.c b/editor/specialty/pgmbentley.c new file mode 100644 index 00000000..aed92074 --- /dev/null +++ b/editor/specialty/pgmbentley.c @@ -0,0 +1,74 @@ +/* pgmbentley.c - read a portable graymap and smear it according to brightness +** +** Copyright (C) 1990 by Wilson Bent (whb@hoh-2.att.com) +** +** Permission to use, copy, modify, and distribute this software and its +** documentation for any purpose and without fee is hereby granted, provided +** that the above copyright notice appear in all copies and that both that +** copyright notice and this permission notice appear in supporting +** documentation. This software is provided "as is" without express or +** implied warranty. +*/ + +#include <stdio.h> + +#include "pm_c_util.h" +#include "pgm.h" + + +static unsigned int const N = 4; + + +int +main(int argc, const char * argv[]) { + + FILE * ifP; + int rows, cols; + gray maxval; + gray ** gin; + gray ** gout; + unsigned int row; + const char * inputFileName; + + pm_proginit(&argc, argv); + + if (argc-1 < 1) + inputFileName = "-"; + else { + inputFileName = argv[1]; + + if (argc-1 > 1) + pm_error("There are no options and only one argument. " + "You specified %u", argc-1); + } + ifP = pm_openr(inputFileName); + + gin = pgm_readpgm(ifP, &cols, &rows, &maxval); + + pm_close(ifP); + + gout = pgm_allocarray(cols, rows); + + for (row = 0; row < rows; ++row) { + unsigned int col; + for (col = 0; col < cols; ++col) + gout[row][col] = 0; + } + + for (row = 0; row < rows; ++row) { + unsigned int col; + + for (col = 0; col < cols; ++col) { + unsigned int const brow = MIN(rows-1, row + gin[row][col] / N); + + gout[brow][col] = gin[row][col]; + } + } + + pgm_writepgm(stdout, gout, cols, rows, maxval, 0); + + pm_close(stdout); + pgm_freearray(gout, rows); + + return 0; +} |