about summary refs log tree commit diff
path: root/converter/ppm/ppmtoppm.c
diff options
context:
space:
mode:
Diffstat (limited to 'converter/ppm/ppmtoppm.c')
-rw-r--r--converter/ppm/ppmtoppm.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/converter/ppm/ppmtoppm.c b/converter/ppm/ppmtoppm.c
new file mode 100644
index 00000000..500c9856
--- /dev/null
+++ b/converter/ppm/ppmtoppm.c
@@ -0,0 +1,44 @@
+/*----------------------------------------------------------------------------
+                               ppmtoppm
+------------------------------------------------------------------------------
+  Part of the Netpbm package.
+
+  Copy PPM image from Standard Input to Standard Output
+
+
+  By Bryan Henderson, San Jose CA 2002.09.07
+
+  Contributed to the public domain by its author 2002.09.07
+-----------------------------------------------------------------------------*/
+
+#include "ppm.h"
+
+int
+main(int argc, char *argv[]) {
+    int format;
+    int rows, cols;
+    pixval maxval;
+    int row;
+    pixel* pixelrow;
+    
+    ppm_init(&argc, argv);
+
+    if (argc-1 != 0)
+        pm_error("Program takes no arguments.  Input is from Standard Input");
+
+    ppm_readppminit(stdin, &cols, &rows, &maxval, &format);
+
+    ppm_writeppminit(stdout, cols, rows, maxval, 0);
+
+    pixelrow = ppm_allocrow(cols);
+
+    for (row = 0; row < rows; row++) {
+        ppm_readppmrow(stdin, pixelrow, cols, maxval, format);
+        ppm_writeppmrow(stdout, pixelrow, cols, maxval, 0);
+    }
+    ppm_freerow(pixelrow);
+
+    pm_close(stdin);
+
+    exit(0);
+}