Index: trunk/pswarp/src/pswarpTransformTile.c
===================================================================
--- trunk/pswarp/src/pswarpTransformTile.c	(revision 29331)
+++ trunk/pswarp/src/pswarpTransformTile.c	(revision 34800)
@@ -46,4 +46,8 @@
     args->jacobian = NAN;
 
+    args->background_warping = false;
+    args->offset_x = 0.0;
+    args->offset_y = 0.0;
+    
     return args;
 }
@@ -83,16 +87,32 @@
     // Iterate over the output image pixels (parent frame)
     long goodPixels = 0;                ///< Number of input pixels landing on the output image
+
     for (int y = yMin; y < yMax; y++) {
         for (int x = xMin; x < xMax; x++) {
-
             // Only transform those pixels requested
             if (region && region->data.PS_TYPE_IMAGE_MASK_DATA[y][x]) {
                 continue;
             }
-
             // pswarpMapApply converts the output coordinate (x,y) to the input coordinate.
             // both are in the parent frames of the input and output images.
             double xIn, yIn;            // Input pixel coordinates
             pswarpMapApply(&xIn, &yIn, map, x + 0.5, y + 0.5);
+
+	    // This needs to use a more reliable method to do this offset and limiting
+	    //	    if (args->interp->mode == 8) {
+	    if (args->background_warping) {
+	      //	      double xOffset = 177.0 / 400.0; // (modelsize * modelbinning - xsize) / 2.0
+	      //	      double yOffset = 166.0 / 400.0; // (modelsize * modelbinning - ysize) / 2.0
+	      xIn += args->offset_x;
+	      yIn += args->offset_y;
+
+	      if ((xIn > inNumCols - args->offset_x)||
+		  (yIn > inNumRows - args->offset_y)||
+		  (xIn < args->offset_x)||
+		  (yIn < args->offset_y)) {
+		continue;
+	      }
+	    }
+	    
             if (xIn < 0 || xIn >= inNumCols || yIn < 0 || yIn >= inNumRows) {
                 continue;
