Index: trunk/ppstamp/src/ppstampRegion.c
===================================================================
--- trunk/ppstamp/src/ppstampRegion.c	(revision 15323)
+++ trunk/ppstamp/src/ppstampRegion.c	(revision 15363)
@@ -21,6 +21,15 @@
     // pmReadoutExtent ignores the col0, row0 of the readout
 
-    int col0 = image->col0;
-    int row0 = image->row0;
+    int col0 = 0;
+    int row0 = 0;
+   
+#ifdef notdef
+    if (image->parent) {
+        // This is wrong. I'm trying to deal with the strange megacam 'spliced' images
+        // which appear to have inconsistant CELL.X0 and readout.col0
+        col0 = image->col0 - image->parent->col0;
+        row0 = image->row0 - image->parent->row0;
+    }
+#endif
 
     return psRegionAlloc(col0, col0 + image->numCols,
@@ -44,6 +53,41 @@
         psFree(roExtent);
     }
-    // Unlike pmCellExtent we don't add in cell.x0, cell.y0. The appropriate offset
-    // was included in the roExtent by ppstampReadoutRegion
+
+    bool mdok;                          // Status of MD lookup
+    int cellX0 = psMetadataLookupS32(&mdok, cell->concepts, "CELL.X0"); // Cell x offset
+    if (!mdok) {
+        psError(PS_ERR_UNKNOWN, true, "Unable to find CELL.X0.\n");
+        psFree(cellExtent);
+        return NULL;
+    }
+
+    int cellY0 = psMetadataLookupS32(&mdok, cell->concepts, "CELL.Y0"); // Cell y offset
+    if (!mdok) {
+        psError(PS_ERR_UNKNOWN, true, "Unable to find CELL.Y0.\n");
+        psFree(cellExtent);
+        return NULL;
+    }
+    int xParity = psMetadataLookupS32(NULL, cell->concepts, "CELL.XPARITY");
+    int yParity = psMetadataLookupS32(NULL, cell->concepts, "CELL.YPARITY");
+
+    if (xParity >= 0) {
+        cellExtent->x0 += cellX0;
+        cellExtent->x1 += cellX0;
+    } else {
+        float x0 = cellX0 - cellExtent->x1;
+        float x1 = cellX0 - cellExtent->x0;
+        cellExtent->x0 = x0;
+        cellExtent->x1 = x1;
+    }
+
+    if (yParity >= 0) {
+        cellExtent->y0 += cellY0;
+        cellExtent->y1 += cellY0;
+    } else {
+        float y0 = cellY0 - cellExtent->y1;
+        float y1 = cellY0 - cellExtent->y0;
+        cellExtent->y0 = y0;
+        cellExtent->y1 = y1;
+    }
 
     return cellExtent;
