Index: trunk/psLib/src/image/psImageManip.c
===================================================================
--- trunk/psLib/src/image/psImageManip.c	(revision 2807)
+++ trunk/psLib/src/image/psImageManip.c	(revision 2835)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-12-23 19:14:15 $
+ *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-28 01:42:28 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -195,9 +195,10 @@
     psU32 imageColLimit;
     psElemType type;
+    psU32 pixelsOverlaid = 0;
 
     if (image == NULL || overlay == NULL) {
         psError(PS_ERR_BAD_PARAMETER_NULL, true,
                 PS_ERRORTEXT_psImage_IMAGE_NULL);
-        return 1;
+        return pixelsOverlaid;
     }
 
@@ -205,5 +206,5 @@
         psError(PS_ERR_BAD_PARAMETER_NULL, true,
                 PS_ERRORTEXT_psImageManip_OPERATION_NULL);
-        return 1;
+        return pixelsOverlaid;
     }
 
@@ -218,5 +219,5 @@
                 PS_ERRORTEXT_psImageManip_OVERLAY_TYPE_MISMATCH,
                 typeStrOverlay, typeStr);
-        return 2;
+        return pixelsOverlaid;
     }
 
@@ -238,49 +239,54 @@
                 col0, imageColLimit, row0, imageRowLimit,
                 imageNumCols, imageNumRows);
-        return 3;
-    }
-
-    switch (type) {
-
-        #define psImageOverlayCase(DATATYPE) \
-    case PS_TYPE_##DATATYPE: \
-        for (psU32 row=row0;row<imageRowLimit;row++) { \
+        return pixelsOverlaid;
+    }
+
+
+    #define psImageOverlayLoop(DATATYPE,OP) { \
+        for (int row=row0;row<imageRowLimit;row++) { \
             ps##DATATYPE* imageRow = image->data.DATATYPE[row]; \
             ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-row0]; \
-            for (psU32 col=col0;col<imageColLimit;col++) { \
-                switch (*op) { \
-                case '+': \
-                    imageRow[col] += overlayRow[col-col0]; \
-                    break; \
-                case '-': \
-                    imageRow[col] -= overlayRow[col-col0]; \
-                    break; \
-                case '*': \
-                    imageRow[col] *= overlayRow[col-col0]; \
-                    break; \
-                case '/': \
-                    imageRow[col] /= overlayRow[col-col0]; \
-                    break; \
-                case '=': \
-                    imageRow[col] = overlayRow[col-col0]; \
-                    break; \
-                default: \
-                    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
-                            PS_ERRORTEXT_psImageManip_OVERLAY_OPERATOR_INVALID, \
-                            op); \
-                    return 5; \
-                } \
-            } \
-        } \
-        break;
-
+            for (int col=col0;col<imageColLimit;col++) { \
+                imageRow[col] OP overlayRow[col-col0]; \
+            } \
+        } \
+        pixelsOverlaid += (imageRowLimit - row0) * (imageColLimit - col0); \
+    }
+
+    #define psImageOverlayCase(DATATYPE) \
+case PS_TYPE_##DATATYPE: \
+    switch (*op) { \
+    case '+': \
+        psImageOverlayLoop(DATATYPE,+=); \
+        break; \
+    case '-': \
+        psImageOverlayLoop(DATATYPE,-=); \
+        break; \
+    case '*': \
+        psImageOverlayLoop(DATATYPE,*=); \
+        break; \
+    case '/': \
+        psImageOverlayLoop(DATATYPE,/=); \
+        break; \
+    case '=': \
+        psImageOverlayLoop(DATATYPE,=); \
+        break; \
+    default: \
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+                PS_ERRORTEXT_psImageManip_OVERLAY_OPERATOR_INVALID, \
+                op); \
+        return pixelsOverlaid; \
+    } \
+    break;
+
+    switch (type) {
         psImageOverlayCase(U8);
         psImageOverlayCase(U16);
-        //        psImageOverlayCase(U32);       Not a requirement
-        //        psImageOverlayCase(U64);       Not a requirement
+        psImageOverlayCase(U32);       // Not a requirement
+        psImageOverlayCase(U64);       // Not a requirement
         psImageOverlayCase(S8);
         psImageOverlayCase(S16);
-        //        psImageOverlayCase(S32);       Not a requirement
-        //        psImageOverlayCase(S64);       Not a requirement
+        psImageOverlayCase(S32);       // Not a requirement
+        psImageOverlayCase(S64);       // Not a requirement
         psImageOverlayCase(F32);
         psImageOverlayCase(F64);
@@ -294,9 +300,9 @@
                     PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
                     typeStr);
-            return 6;
-        }
-    }
-
-    return 0;
+            return pixelsOverlaid;
+        }
+    }
+
+    return pixelsOverlaid;
 }
 
@@ -832,18 +838,18 @@
 
         /* optimized public domain rotation routine by Karl Lager
-         * 
-         * float cosT,sinT; 
-         * cosT = cos(t); 
-         * sinT = sin(t); 
-         * for (y = min_y; y <= max_y; y++) { 
-         *     x' = min_x * cosT + y * sinT + x1'; 
-         *     y' = y * cosT - min_x * sinT + y1'; 
-         *     for (x = min_x; x <= max_x; x++) { 
+         *
+         * float cosT,sinT;
+         * cosT = cos(t);
+         * sinT = sin(t);
+         * for (y = min_y; y <= max_y; y++) {
+         *     x' = min_x * cosT + y * sinT + x1';
+         *     y' = y * cosT - min_x * sinT + y1';
+         *     for (x = min_x; x <= max_x; x++) {
          *         if (x', y') is in the bounds of the bitmap, get pixel
-         *            (x', y') and plot the pixel to (x, y) on screen. 
-         *         x' += cosT; 
-         *         y' -= sinT; 
+         *            (x', y') and plot the pixel to (x, y) on screen.
+         *         x' += cosT;
+         *         y' -= sinT;
          *     }
-         * } 
+         * }
          */
 
