about summary refs log tree commit diff
path: root/editor/pgmbentley.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
commit1fd361a1ea06e44286c213ca1f814f49306fdc43 (patch)
tree64c8c96cf54d8718847339a403e5e67b922e8c3f /editor/pgmbentley.c
downloadnetpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.gz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.xz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.zip
Create Subversion repository
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor/pgmbentley.c')
-rw-r--r--editor/pgmbentley.c64
1 files changed, 64 insertions, 0 deletions
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 <stdio.h>
+#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 );
+    }