Index: trunk/psLib/src/imageops/psImagePixelManip.c
===================================================================
--- trunk/psLib/src/imageops/psImagePixelManip.c	(revision 4589)
+++ trunk/psLib/src/imageops/psImagePixelManip.c	(revision 4815)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-07-21 01:40:10 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-08-18 21:44:40 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -396,2 +396,118 @@
 }
 
+// mask the area contained by the region
+// the region is defined wrt the parent image
+void psImageMaskRegion(psImage *image,
+                       psRegion *region,
+                       bool logical_and,
+                       int maskValue)
+{
+
+    for (int iy = 0; iy < image->numRows; iy++) {
+        for (int ix = 0; ix < image->numCols; ix++) {
+            if (ix + image->col0 <  region->x0)
+                continue;
+            if (ix + image->col0 >= region->x1)
+                continue;
+            if (iy + image->row0 <  region->y0)
+                continue;
+            if (iy + image->row0 >= region->y1)
+                continue;
+            if (logical_and) {
+                image->data.U8[iy][ix] &= maskValue;
+            } else {
+                image->data.U8[iy][ix] |= maskValue;
+            }
+        }
+    }
+}
+
+// mask the area not contained by the region
+// the region is defined wrt the parent image
+void psImageKeepRegion(psImage *image,
+                       psRegion *region,
+                       bool logical_and,
+                       int maskValue)
+{
+
+    for (int iy = 0; iy < image->numRows; iy++) {
+        for (int ix = 0; ix < image->numCols; ix++) {
+            if (ix + image->col0 <  region->x0)
+                goto maskit;
+            if (ix + image->col0 >= region->x1)
+                goto maskit;
+            if (iy + image->row0 <  region->y0)
+                goto maskit;
+            if (iy + image->row0 >= region->y1)
+                goto maskit;
+            continue;
+maskit:
+            if (logical_and) {
+                image->data.U8[iy][ix] &= maskValue;
+            } else {
+                image->data.U8[iy][ix] |= maskValue;
+            }
+        }
+    }
+}
+
+// mask the area contained by the region
+// the region is defined wrt the parent image
+void psImageMaskCircle(psImage *image,
+                       double x,
+                       double y,
+                       double radius,
+                       bool logical_and,
+                       int maskValue)
+{
+
+    double dx, dy, r2, R2;
+
+    R2 = PS_SQR(radius);
+
+    for (int iy = 0; iy < image->numRows; iy++) {
+        for (int ix = 0; ix < image->numCols; ix++) {
+            dx = ix + image->col0 - x;
+            dy = iy + image->row0 - y;
+            r2 = PS_SQR(dx) + PS_SQR(dy);
+            if (r2 > R2)
+                continue;
+            if (logical_and) {
+                image->data.U8[iy][ix] &= maskValue;
+            } else {
+                image->data.U8[iy][ix] |= maskValue;
+            }
+        }
+    }
+}
+
+// mask the area contained by the region
+// the region is defined wrt the parent image
+void psImageKeepCircle(psImage *image,
+                       double x,
+                       double y,
+                       double radius,
+                       bool logical_and,
+                       int maskValue)
+{
+
+    double dx, dy, r2, R2;
+
+    R2 = PS_SQR(radius);
+
+    for (int iy = 0; iy < image->numRows; iy++) {
+        for (int ix = 0; ix < image->numCols; ix++) {
+            dx = ix + image->col0 - x;
+            dy = iy + image->row0 - y;
+            r2 = PS_SQR(dx) + PS_SQR(dy);
+            if (r2 < R2)
+                continue;
+            if (logical_and) {
+                image->data.U8[iy][ix] &= maskValue;
+            } else {
+                image->data.U8[iy][ix] |= maskValue;
+            }
+        }
+    }
+}
+
