about summary refs log tree commit diff
path: root/converter/other/srftopam.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2011-05-25 03:02:46 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2011-05-25 03:02:46 +0000
commitbe68d56e96c48d548b33b487f12bf7850e9cb92c (patch)
tree86a0d5e5940df9f32ee6e00664edf6b20df1cdf8 /converter/other/srftopam.c
parentf621ebcdaa736bed6cbb37ca28082e722398249b (diff)
downloadnetpbm-mirror-be68d56e96c48d548b33b487f12bf7850e9cb92c.tar.gz
netpbm-mirror-be68d56e96c48d548b33b487f12bf7850e9cb92c.tar.xz
netpbm-mirror-be68d56e96c48d548b33b487f12bf7850e9cb92c.zip
Make one PAM image per SRF image
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1490 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other/srftopam.c')
-rw-r--r--converter/other/srftopam.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/converter/other/srftopam.c b/converter/other/srftopam.c
index 398077f3..efe55253 100644
--- a/converter/other/srftopam.c
+++ b/converter/other/srftopam.c
@@ -152,30 +152,20 @@ writeRaster(struct pam *     const pamP,
 
 
 static void
-srftopam(struct cmdlineInfo const cmdline,
-         FILE *             const ifP,
-         FILE *             const ofP) {
+convertOneImage(struct srf_img * const imgP,
+                FILE *           const ofP) {
 
     const char * comment = "Produced by srftopam";  /* constant */
-    long         width, height;
-    unsigned int i;
-    struct srf   srf;
-    struct pam   outPam;
-
-    srf_read(ifP, verbose, &srf);
 
-    for (i = 0, width = 0, height = 0; i < srf.header.img_cnt; ++i) {
-        width = MAX(width, srf.imgs[i].header.width);
-        height += srf.imgs[i].header.height;
-    }
+    struct pam   outPam;
 
     outPam.size             = sizeof(struct pam);
     outPam.len              = PAM_STRUCT_SIZE(comment_p);
     outPam.file             = ofP;
     outPam.format           = PAM_FORMAT;
     outPam.plainformat      = 0;
-    outPam.width            = width;
-    outPam.height           = height;
+    outPam.width            = imgP->header.width;
+    outPam.height           = imgP->header.height;
     outPam.depth            = 4;
     outPam.maxval           = 255;
     outPam.bytes_per_sample = 1;
@@ -185,8 +175,26 @@ srftopam(struct cmdlineInfo const cmdline,
 
     pnm_writepaminit(&outPam);
 
-    for (i = 0; i < srf.header.img_cnt; ++i)
-        writeRaster(&outPam, &srf.imgs[i]);
+    writeRaster(&outPam, imgP);
+}
+
+
+
+static void
+srftopam(struct cmdlineInfo const cmdline,
+         FILE *             const ifP,
+         FILE *             const ofP) {
+
+    unsigned int imgSeq;
+    struct srf   srf;
+
+    srf_read(ifP, verbose, &srf);
+
+    for (imgSeq = 0; imgSeq < srf.header.img_cnt; ++imgSeq) {
+        if (verbose)
+            pm_message("Converting Image %u", imgSeq);
+        convertOneImage(&srf.imgs[imgSeq], ofP);
+    }
 
     srf_term(&srf);
 }