about summary refs log tree commit diff
path: root/converter/other/srf.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/srf.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/srf.c')
-rw-r--r--converter/other/srf.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/converter/other/srf.c b/converter/other/srf.c
index 508d40a0..ded049ac 100644
--- a/converter/other/srf.c
+++ b/converter/other/srf.c
@@ -593,7 +593,7 @@ srf_img_init(struct srf_img * const imgP,
 
 static void
 initPstring(struct srf_pstring * const pstringP,
-                 const char *         const s) {
+            const char *         const s) {
 
     pstringP->len = strlen(s);
 
@@ -610,23 +610,14 @@ initPstring(struct srf_pstring * const pstringP,
 
 
 void
-srf_init(struct srf * const srfP,
-         uint32_t     const imgCnt,
-         uint16_t     const width3d,
-         uint16_t     const height3d,
-         uint16_t     const widthOv,
-         uint16_t     const heightOv) {
+srf_init(struct srf * const srfP) {
 
     struct srf_header * const headerP = &srfP->header;
-    unsigned int i;
-
-    if (imgCnt == 0 || imgCnt % 2 != 0)
-        pm_error("invalid image count");
 
     strcpy(headerP->magic, SRF_MAGIC);
     headerP->_int4[0] = 4;
     headerP->_int4[1] = 4;
-    headerP->img_cnt = imgCnt;
+    headerP->img_cnt = 0;
     headerP->_int5 = 5;
     initPstring(&headerP->s578, "578");
     headerP->_int6 = 6;
@@ -634,16 +625,30 @@ srf_init(struct srf * const srfP,
     headerP->_int7 = 7;
     initPstring(&headerP->prod, "006-D0578-XX");
 
-    MALLOCARRAY(srfP->imgs, headerP->img_cnt);
+    srfP->imgs = NULL;
+}
 
-    if (!srfP->imgs)
-        pm_error("Could not allocate memory for %u images", headerP->img_cnt);
 
-    for (i = 0; i < headerP->img_cnt; i += 2) {
-        srf_img_init(&srfP->imgs[i], width3d, height3d);
-        srf_img_init(&srfP->imgs[i + 1], widthOv, heightOv);
-    }
-}
 
+void
+srf_create_img(struct srf * const srfP,
+               uint16_t     const width,
+               uint16_t     const height) {
+/*----------------------------------------------------------------------------
+   Add an "image" to the SRF.  An image is a horizontal series of 36 
+   square frames, each showing a different angle view of an object, 10
+   degrees about.  At least that's what it's supposed to be.  We don't
+   really care -- it's just an arbitrary rectangular raster image to us.
+-----------------------------------------------------------------------------*/
+    
+    ++srfP->header.img_cnt;
 
+    REALLOCARRAY(srfP->imgs, srfP->header.img_cnt);
 
+    if (!srfP->imgs)
+        pm_error("Could not allocate memory for %u images",
+                 srfP->header.img_cnt);
+
+    srf_img_init(&srfP->imgs[srfP->header.img_cnt-1], width, height);
+}
+