Index: trunk/psLib/src/imageops/psImagePixelManip.c
===================================================================
--- trunk/psLib/src/imageops/psImagePixelManip.c	(revision 12250)
+++ trunk/psLib/src/imageops/psImagePixelManip.c	(revision 12256)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-01-09 22:38:52 $
+ *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-03-06 03:09:58 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -261,4 +261,19 @@
     }
 
+    #define psImageOverlayLoopDivide(DATATYPE,BADVALUE) { \
+        for (int row=y0;row<imageRowLimit;row++) { \
+            ps##DATATYPE* imageRow = image->data.DATATYPE[row]; \
+            ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-y0]; \
+            for (int col=x0;col<imageColLimit;col++) { \
+                if (overlayRow[col-x0] == 0) { \
+                    imageRow[col] = BADVALUE; \
+                    continue; \
+                } \
+                imageRow[col] /= overlayRow[col-x0]; \
+            } \
+        } \
+        pixelsOverlaid += (imageRowLimit - y0) * (imageColLimit - x0); \
+    }
+
     // Use memcpy to perform the '=' operation.  Depending on the particular application, it can be about 20%
     // faster than using a 'for' loop.  Josh Hoblitt says it has an additional advantage that it doesn't blow
@@ -279,5 +294,5 @@
     }
 
-    #define psImageOverlayCase(DATATYPE) \
+    #define psImageOverlayCase(DATATYPE,BADVALUE) \
 case PS_TYPE_##DATATYPE: \
     switch (*op) { \
@@ -292,5 +307,5 @@
         break; \
     case '/': \
-        psImageOverlayLoop(DATATYPE,/=); \
+        psImageOverlayLoopDivide(DATATYPE,BADVALUE); \
         break; \
     case '=': \
@@ -306,16 +321,16 @@
 
     switch (type) {
-        psImageOverlayCase(U8);
-        psImageOverlayCase(U16);
-        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(F32);
-        psImageOverlayCase(F64);
-        psImageOverlayCase(C32);
-        psImageOverlayCase(C64);
+        psImageOverlayCase(U8, 0);
+        psImageOverlayCase(U16,0);
+        psImageOverlayCase(U32,0);       // Not a requirement
+        psImageOverlayCase(U64,0);       // Not a requirement
+        psImageOverlayCase(S8, 0);
+        psImageOverlayCase(S16,0);
+        psImageOverlayCase(S32,0);       // Not a requirement
+        psImageOverlayCase(S64,0);       // Not a requirement
+        psImageOverlayCase(F32,NAN);
+        psImageOverlayCase(F64,NAN);
+        psImageOverlayCase(C32,NAN);
+        psImageOverlayCase(C64,NAN);
 
     default: {
