about summary refs log tree commit diff
path: root/converter/other
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2007-11-02 02:18:06 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2007-11-02 02:18:06 +0000
commitd96bde81debfc04437c0c18ff9949459732efe79 (patch)
tree123eb5bea45df6182332bbcd8f7f5a19d5e0d996 /converter/other
parent24afcf35fbdbe2435ccc11ad370380018c3ff8f0 (diff)
downloadnetpbm-mirror-d96bde81debfc04437c0c18ff9949459732efe79.tar.gz
netpbm-mirror-d96bde81debfc04437c0c18ff9949459732efe79.tar.xz
netpbm-mirror-d96bde81debfc04437c0c18ff9949459732efe79.zip
Add pamtopam
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@451 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other')
-rw-r--r--converter/other/Makefile2
-rw-r--r--converter/other/pamtopam.c53
2 files changed, 54 insertions, 1 deletions
diff --git a/converter/other/Makefile b/converter/other/Makefile
index 976c215a..3e2c2faa 100644
--- a/converter/other/Makefile
+++ b/converter/other/Makefile
@@ -81,7 +81,7 @@ PORTBINARIES =  bmptopnm fitstopnm \
 		gemtopnm giftopnm hdifftopam infotopam \
 		pamtodjvurle pamtofits pamtogif \
 		pamtohdiff pamtohtmltbl pamtooctaveimg \
-		pamtopfm pamtopnm pamtouil \
+		pamtopam pamtopfm pamtopnm pamtouil \
 		pamtoxvmini \
 		pbmtopgm pfmtopam \
 	        pgmtopbm pgmtoppm ppmtopgm pnmtoddif \
diff --git a/converter/other/pamtopam.c b/converter/other/pamtopam.c
new file mode 100644
index 00000000..d1a88fd6
--- /dev/null
+++ b/converter/other/pamtopam.c
@@ -0,0 +1,53 @@
+/*----------------------------------------------------------------------------
+                               pamtopam
+------------------------------------------------------------------------------
+  Part of the Netpbm package.
+
+  Copy PAM and PNM (i.e. PBM, PGM, or PPM) images from Standard Input
+  to Standard Output (while converting PNM images to PAM)
+-----------------------------------------------------------------------------*/
+
+#include "pm_c_util.h"
+#include "pam.h"
+
+int
+main(int argc, char *argv[]) {
+
+    bool       eof;     /* no more images in input stream */
+    struct pam inpam;   /* Input PAM image */
+    struct pam outpam;  /* Output PAM image */
+
+    pm_proginit(&argc, argv);
+
+    if (argc-1 != 0)
+        pm_error("Program takes no arguments.  Input is from Standard Input");
+
+    eof = FALSE;
+    while (!eof) {
+        pnm_readpaminit(stdin, &inpam, PAM_STRUCT_SIZE(tuple_type));
+
+        outpam = inpam;
+        outpam.file = stdout;
+        outpam.format = PAM_FORMAT;
+
+        pnm_writepaminit(&outpam);
+
+        {
+            tuple * tuplerow;
+
+            tuplerow = pnm_allocpamrow(&inpam);
+            {
+                unsigned int row;
+
+                for (row = 0; row < inpam.height; ++row) {
+                    pnm_readpamrow(&inpam, tuplerow);
+                    pnm_writepamrow(&outpam, tuplerow);
+                }
+            }
+            pnm_freepamrow(tuplerow);
+        }
+        pnm_nextimage(stdin, &eof);
+    }
+
+    return 0;
+}