From 1fd361a1ea06e44286c213ca1f814f49306fdc43 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sat, 19 Aug 2006 03:12:28 +0000 Subject: Create Subversion repository git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- editor/pgmbentley.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 editor/pgmbentley.c (limited to 'editor/pgmbentley.c') diff --git a/editor/pgmbentley.c b/editor/pgmbentley.c new file mode 100644 index 00000000..9cc86a91 --- /dev/null +++ b/editor/pgmbentley.c @@ -0,0 +1,64 @@ +/* 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 +#include "pgm.h" + +int +main( argc, argv ) + int argc; + char* argv[]; + { + FILE* ifp; + gray maxval; + gray** gin; + gray** gout; + int argn, rows, cols, row; + register int brow, col; + const char* const usage = "[pgmfile]"; + + + pgm_init( &argc, argv ); + + argn = 1; + + if ( argn < argc ) + { + ifp = pm_openr( argv[argn] ); + ++argn; + } + else + ifp = stdin; + + if ( argn != argc ) + pm_usage( usage ); + + gin = pgm_readpgm( ifp, &cols, &rows, &maxval ); + pm_close( ifp ); + gout = pgm_allocarray( cols, rows ); + +#define N 4 + for ( row = 0; row < rows; ++row ) + for ( col = 0; col < cols; ++col ) + { + brow = row + (int) (gin[row][col]) / N; + if ( brow >= rows ) + brow = rows - 1; + gout[brow][col] = gin[row][col]; + } + + pgm_writepgm( stdout, gout, cols, rows, maxval, 0 ); + pm_close( stdout ); + pgm_freearray( gout, rows ); + + exit( 0 ); + } -- cgit 1.4.1