Index: trunk/Ohana/src/opihi/dvo/imbox.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/imbox.c	(revision 21065)
+++ trunk/Ohana/src/opihi/dvo/imbox.c	(revision 25757)
@@ -3,5 +3,5 @@
 int imbox (int argc, char **argv) {
   
-  int j, kapa, Nskip, status, InPic, flipped, N, haveNx, haveNy, Nx, Ny, SOLO_PHU;
+  int j, kapa, Nskip, status, InPic, flipped, N, haveNx, haveNy, Nx, Ny, SOLO_PHU, Npts, NPTS;
   Vector Xvec, Yvec;
   double r, d, x[4], y[4], Rmin, Rmax, Rmid;
@@ -36,6 +36,8 @@
   
   /* project this image to screen display coords */
-  SetVector (&Xvec, OPIHI_FLT, 8);
-  SetVector (&Yvec, OPIHI_FLT, 8);
+  Npts = 0;
+  NPTS = 200; 
+  SetVector (&Xvec, OPIHI_FLT, NPTS);
+  SetVector (&Yvec, OPIHI_FLT, NPTS);
 
   while (gfits_fread_header (f, &header)) {
@@ -82,28 +84,30 @@
 	while (r > Rmid) r-= 360.0;
       }
-      status |= RD_to_XY (&Xvec.elements.Flt[2*j], &Yvec.elements.Flt[2*j], r, d, &graphmode.coords);
+      status |= RD_to_XY (&Xvec.elements.Flt[Npts + 2*j], &Yvec.elements.Flt[Npts + 2*j], r, d, &graphmode.coords);
       if (j > 0) {
-	Xvec.elements.Flt[2*j - 1] = Xvec.elements.Flt[2*j];
-	Yvec.elements.Flt[2*j - 1] = Yvec.elements.Flt[2*j];
+	Xvec.elements.Flt[Npts + 2*j - 1] = Xvec.elements.Flt[Npts + 2*j];
+	Yvec.elements.Flt[Npts + 2*j - 1] = Yvec.elements.Flt[Npts + 2*j];
       }
     }
-    Xvec.elements.Flt[7] = Xvec.elements.Flt[0];
-    Yvec.elements.Flt[7] = Yvec.elements.Flt[0];
+    Xvec.elements.Flt[Npts + 7] = Xvec.elements.Flt[Npts + 0];
+    Yvec.elements.Flt[Npts + 7] = Yvec.elements.Flt[Npts + 0];
+
     InPic = FALSE;
     for (j = 0; j < 8; j+=2) {
-      if ((Xvec.elements.Flt[j] >= graphmode.xmin) && 
-	  (Xvec.elements.Flt[j] <= graphmode.xmax) && 
-	  (Yvec.elements.Flt[j] >= graphmode.ymin) && 
-	  (Yvec.elements.Flt[j] <= graphmode.ymax))
-	InPic = TRUE;
+      if ((Xvec.elements.Flt[Npts + j] >= graphmode.xmin) && 
+    	  (Xvec.elements.Flt[Npts + j] <= graphmode.xmax) && 
+    	  (Yvec.elements.Flt[Npts + j] >= graphmode.ymin) && 
+    	  (Yvec.elements.Flt[Npts + j] <= graphmode.ymax))
+    	InPic = TRUE;
+    }
+    if (!InPic) continue;
+
+    Npts += 8;
+    if (Npts + 8 >= NPTS) {  /* need to leave room for 4 point image */
+      NPTS += 200;
+      REALLOCATE (Xvec.elements.Flt, opihi_flt, NPTS);
+      REALLOCATE (Yvec.elements.Flt, opihi_flt, NPTS);
     }
 
-    Xvec.Nelements = Yvec.Nelements = 8;
-    if (InPic) {
-      graphmode.style = 2; /* points */
-      graphmode.ptype = 100; /* connect pairs of points */
-      graphmode.etype = 0;
-      PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
-    }
   skip:
     Nskip = gfits_data_size (&header);
@@ -111,4 +115,13 @@
     gfits_free_header (&header);
   }
+
+  Xvec.Nelements = Yvec.Nelements = Npts;
+  if (Npts > 0) {
+    graphmode.style = 2; /* points */
+    graphmode.ptype = 100; /* connect pairs of points */
+    graphmode.etype = 0;
+    PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
+  }
+
   fclose (f);
   free (Xvec.elements.Flt);
