Index: trunk/psModules/src/camera/pmFPAMosaic.c
===================================================================
--- trunk/psModules/src/camera/pmFPAMosaic.c	(revision 7634)
+++ trunk/psModules/src/camera/pmFPAMosaic.c	(revision 7641)
@@ -468,8 +468,10 @@
         int xParity = xFlip->data.U8[i] ? -1 : 1; // Parity difference, in x
         int yParity = yFlip->data.U8[i] ? -1 : 1; // Parity difference, in y
+        int xTargetBase = (x0->data.S32[i] - xMin) / xBinTarget; // The base x position in the target frame
+        int yTargetBase = (y0->data.S32[i] - yMin) / yBinTarget; // The base y position in the target frame
         if (xBinSource->data.S32[i] == xBinTarget && yBinSource->data.S32[i] == yBinTarget &&
                 xFlip->data.U8[i] == 0 && yFlip->data.U8[i] == 0) {
-            // Let someone else do the hard work; useful to test psImageOverlaySection if no other reason
-            psImageOverlaySection(mosaic, image, x0->data.S32[i] - xMin, y0->data.S32[i] - yMin, "+");
+            // Let someone else do the hard work
+            psImageOverlaySection(mosaic, image, xTargetBase, yTargetBase, "+");
         } else if (xBinSource->data.S32[i] == xBinTarget && yBinSource->data.S32[i] == yBinTarget) {
             // There's a difference with the parities, but we don't have to worry about binning
@@ -477,6 +479,4 @@
             #define COPY_WITH_PARITY_DIFFERENCE(TYPE) \
         case PS_TYPE_##TYPE: { \
-                int yTargetBase = (y0->data.S32[i] - yMin) / yBinTarget; \
-                int xTargetBase = (x0->data.S32[i] - xMin) / xBinTarget; \
                 for (int y = 0; y < image->numRows; y++) { \
                     int yTarget =  yTargetBase + yParity * y; \
@@ -501,18 +501,14 @@
             // In case the original image is binned but the mosaic is not, we need to fill in the
             // values in the mosaic.
-
-
             #define FILL_IN(TYPE) \
         case PS_TYPE_##TYPE: \
             for (int y = 0; y < image->numRows; y++) { \
-                float yTargetBase = (y0->data.S32[i] + yParity * yBinSource->data.S32[i] * y - yMin) / \
-                                    yBinTarget; \
+                float yTargetBinBase = yTargetBase + yParity * yBinSource->data.S32[i] * y / yBinTarget; \
                 for (int x = 0; x < image->numCols; x++) { \
-                    float xTargetBase = (x0->data.S32[i] + xParity * xBinSource->data.S32[i] * x - xMin) / \
-                                        xBinTarget; \
+                    float xTargetBinBase = xTargetBase + xParity * xBinSource->data.S32[i] * x / xBinTarget; \
                     for (int j = 0; j < yBinSource->data.S32[i]; j++) { \
-                        int yTarget = (int)(yTargetBase + yParity * (float)j / (float)yBinTarget); \
+                        int yTarget = (int)(yTargetBinBase + yParity * (float)j / (float)yBinTarget); \
                         for (int k = 0; k < xBinSource->data.S32[i]; k++) { \
-                            int xTarget = (int)(xTargetBase + xParity * (float)k / (float)xBinTarget); \
+                            int xTarget = (int)(xTargetBinBase + xParity * (float)k / (float)xBinTarget); \
                             mosaic->data.TYPE[yTarget][xTarget] += image->data.TYPE[y][x]; \
                         } \
