Index: trunk/psLib/src/imageops/psImageGeomManip.c
===================================================================
--- trunk/psLib/src/imageops/psImageGeomManip.c	(revision 20299)
+++ trunk/psLib/src/imageops/psImageGeomManip.c	(revision 21183)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-10-21 22:10:53 $
+ *  @version $Revision: 1.45 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:37 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -39,5 +39,5 @@
                       const psImage* in,
                       const psImage* mask,
-                      psMaskType maskVal,
+                      psImageMaskType maskVal,
                       int scale,
                       const psStats* stats)
@@ -47,8 +47,8 @@
     psS32 outRows;
     psS32 outCols;
-    psVector* vec;                     // vector to hold the values of a single bin.
-    psVector* maskVec = NULL;          // vector to hold the mask of a single bin.
-    psMaskType* maskData = NULL;
-    psStats* myStats;
+    psVector *vec;                     // vector to hold the values of a single bin.
+    psVector *maskVec = NULL;          // vector to hold the mask of a single bin.
+    psVectorMaskType *maskData = NULL;
+    psStats *myStats;
 
     if (in == NULL) {
@@ -86,16 +86,16 @@
 
     if (mask != NULL) {
-        if (mask->type.type != PS_TYPE_MASK) {
+        if (mask->type.type != PS_TYPE_IMAGE_MASK) {
             char* typeStr;
             PS_TYPE_NAME(typeStr,mask->type.type);
             psError(PS_ERR_BAD_PARAMETER_TYPE, true,
                     _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
-                    typeStr, PS_TYPE_MASK_NAME);
+                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
             psFree(out);
             psFree(vec);
             return NULL;
         }
-        maskVec = psVectorAllocEmpty(scale * scale, PS_TYPE_MASK);
-        maskData = maskVec->data.PS_TYPE_MASK_DATA;
+        maskVec = psVectorAllocEmpty(scale * scale, PS_TYPE_VECTOR_MASK);
+        maskData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA;
     }
 
@@ -114,5 +114,5 @@
         ps##TYPE *outRowData; \
         ps##TYPE *vecData = vec->data.TYPE; \
-        psMaskType *inRowMask = NULL; \
+        psImageMaskType *inRowMask = NULL; \
         for (psS32 row = 0; row < outRows; row++) { \
             outRowData = out->data.TYPE[row]; \
@@ -126,9 +126,9 @@
                     ps##TYPE* inRowData = in->data.TYPE[inRow]; \
                     if (mask != NULL) { \
-                        inRowMask = mask->data.PS_TYPE_MASK_DATA[inRow]; \
+                        inRowMask = mask->data.PS_TYPE_IMAGE_MASK_DATA[inRow]; \
                     } \
                     for (psS32 inCol = inCurrentCol; inCol < inNextCol && inCol < inCols; inCol++) { \
                         if (maskData != NULL) { \
-                            maskData[n] = inRowMask[inCol]; \
+                            maskData[n] = (inRowMask[inCol] & maskVal); \
                         } \
                         vecData[n++] = inRowData[inCol]; \
@@ -139,5 +139,5 @@
                     maskVec->n = n; \
                 } \
-                psVectorStats(myStats, vec, NULL, maskVec, maskVal); \
+                 psVectorStats(myStats, vec, NULL, maskVec, 0xff); /* the mask vector has only 0 or 1 */ \
                 outRowData[col] = (ps##TYPE)psStatsGetValue(myStats, statistic); \
             } \
@@ -659,5 +659,5 @@
 
 bool psImageShiftMask(psImage **out, psImage **outMask, const psImage* in, const psImage *inMask,
-                      psMaskType maskVal, float dx, float dy, double exposed, psMaskType blank,
+                      psImageMaskType maskVal, float dx, float dy, double exposed, psImageMaskType blank,
                       psImageInterpolateMode mode)
 {
@@ -667,5 +667,5 @@
         PS_ASSERT_IMAGE_NON_NULL(inMask, false);
         PS_ASSERT_IMAGES_SIZE_EQUAL(in, inMask, false);
-        PS_ASSERT_IMAGE_TYPE(inMask, PS_TYPE_MASK, false);
+        PS_ASSERT_IMAGE_TYPE(inMask, PS_TYPE_IMAGE_MASK, false);
     }
 
@@ -675,5 +675,5 @@
     *out = psImageRecycle(*out, numCols, numRows, type);
     if (outMask) {
-        *outMask = psImageRecycle(*outMask, numCols, numRows, PS_TYPE_MASK);
+        *outMask = psImageRecycle(*outMask, numCols, numRows, PS_TYPE_IMAGE_MASK);
     }
 
@@ -702,10 +702,10 @@
     for (int row = 0; row < numRows; row++) { \
         ps##TYPE* outRow = (*out)->data.TYPE[row]; \
-        psMaskType *outMaskRow = (outMask ? (*outMask)->data.PS_TYPE_MASK_DATA[row] : NULL); \
+        psImageMaskType *outMaskRow = (outMask ? (*outMask)->data.PS_TYPE_IMAGE_MASK_DATA[row] : NULL); \
         float y = row + 0.5 - dy; \
         for (int col = 0; col < numCols; col++) { \
             float x = col + 0.5 - dx; \
             double value; \
-            psMaskType valueMask = 0; \
+            psImageMaskType valueMask = 0; \
             if (!psImageInterpolate(&value, NULL, &valueMask, x, y, interp)) { \
                 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); \
@@ -750,5 +750,5 @@
                           const psImage *input,
                           const psImage *inputMask,
-                          psMaskType inputMaskVal,
+                          psImageMaskType inputMaskVal,
                           const psPlaneTransform *outToIn,
                           psRegion region,
@@ -778,10 +778,10 @@
             return NULL;
         }
-        if (inputMask->type.type != PS_TYPE_MASK) {
+        if (inputMask->type.type != PS_TYPE_IMAGE_MASK) {
             char* typeStr;
             PS_TYPE_NAME(typeStr,inputMask->type.type);
             psError(PS_ERR_BAD_PARAMETER_TYPE, true,
                     _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
-                    typeStr, PS_TYPE_MASK_NAME);
+                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
             psFree(output);
             return NULL;
