Index: trunk/psModules/src/camera/pmFPAExtent.c
===================================================================
--- trunk/psModules/src/camera/pmFPAExtent.c	(revision 12710)
+++ trunk/psModules/src/camera/pmFPAExtent.c	(revision 13499)
@@ -10,29 +10,24 @@
     PS_ASSERT_PTR_NON_NULL(readout, NULL);
 
-    if (readout->image) {
-        return psRegionAlloc(readout->col0, readout->image->numCols,
-                             readout->row0, readout->image->numRows);
+    psImage *image = readout->image;    // Image from which to get dimensions
+    if (!image) {
+        image = readout->mask;
     }
-    pmCell *cell = readout->parent;     // The parent cell
-    if (!cell) {
-        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to determine size of readout.\n");
-        return NULL;
-    }
-    bool mdok;                          // Status of MD lookup
-    psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC"); // Trim section
-    if (!mdok || !trimsec) {
-        psError(PS_ERR_UNKNOWN, true, "Unable to find CELL.TRIMSEC.\n");
-        return NULL;
+    if (!image) {
+        image = readout->weight;
     }
 
-    // XXX: Binning?
-    // XXX this is not setting the right value for megacam spliced chip
-    trimsec->x0 = 0;
-    trimsec->y0 = 0;
-    trimsec->x1 = 2112;
-    trimsec->y1 = 4644;
+    if (!image) {
+        // Don't have anything to base the true extent on, so have to give the largest possible extent
+        int xSize = psMetadataLookupS32(NULL, readout->parent->concepts, "CELL.XSIZE");
+        int ySize = psMetadataLookupS32(NULL, readout->parent->concepts, "CELL.YSIZE");
+        return psRegionAlloc(0, xSize, 0, ySize);
+    }
 
-    return psRegionAlloc(readout->col0, trimsec->x1 - trimsec->x0,
-                         readout->row0, trimsec->y1 - trimsec->y0);
+    // Get the offset to the CCD window
+    int xWindow = psMetadataLookupS32(NULL, readout->parent->concepts, "CELL.XWINDOW");
+    int yWindow = psMetadataLookupS32(NULL, readout->parent->concepts, "CELL.YWINDOW");
+    return psRegionAlloc(xWindow, xWindow + image->numCols,
+                         yWindow, yWindow + image->numRows);
 }
 
