Index: trunk/psLib/test/imageops/tap_psImageConvolve2.c
===================================================================
--- trunk/psLib/test/imageops/tap_psImageConvolve2.c	(revision 17320)
+++ trunk/psLib/test/imageops/tap_psImageConvolve2.c	(revision 17330)
@@ -8,4 +8,6 @@
 #define KERNEL_SIZE 3
 #define TOL 1.0e-6
+#define MASK_INITIAL 0x0f
+#define MASK_FINAL   0xf0
 
 
@@ -17,4 +19,13 @@
     image->data.F32[IMAGE_SIZE/2][IMAGE_SIZE/2] = 1.0;
     return image;
+}
+
+// Generate mask with single pixel set
+static psImage *generateMask(void)
+{
+    psImage *mask = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_MASK);
+    psImageInit(mask, 0);
+    mask->data.PS_TYPE_MASK_DATA[IMAGE_SIZE/2][IMAGE_SIZE/2] = MASK_INITIAL;
+    return mask;
 }
 
@@ -58,8 +69,34 @@
 }
 
+// Check the convolved mask matches the kernel
+static bool checkConvolvedMask(const psImage *mask)
+{
+    bool correct = true;
+    for (int y = 0; y < IMAGE_SIZE; y++) {
+        for (int x = 0; x < IMAGE_SIZE; x++) {
+            if (x < IMAGE_SIZE/2 - KERNEL_SIZE || x > IMAGE_SIZE/2 + KERNEL_SIZE ||
+                y < IMAGE_SIZE/2 - KERNEL_SIZE || y > IMAGE_SIZE/2 + KERNEL_SIZE) {
+                if (mask->data.PS_TYPE_MASK_DATA[y][x] != 0) {
+                    diag("%d,%d --> %d", x, y, mask->data.PS_TYPE_MASK_DATA[y][x]);
+                    correct = false;
+                }
+            } else if (x == IMAGE_SIZE/2 && y == IMAGE_SIZE/2) {
+                if (mask->data.PS_TYPE_MASK_DATA[y][x] != (MASK_INITIAL | MASK_FINAL)) {
+                    diag("%d,%d --> %d", x, y, mask->data.PS_TYPE_MASK_DATA[y][x]);
+                    correct = false;
+                }
+            } else if (mask->data.PS_TYPE_MASK_DATA[y][x] != MASK_FINAL) {
+                diag("%d,%d --> %d", x, y, mask->data.PS_TYPE_MASK_DATA[y][x]);
+                correct = false;
+            }
+        }
+    }
+    return correct;
+}
+
 
 int main(int argc, char *argv[])
 {
-    plan_tests(10);
+    plan_tests(15);
 
     diag("psImageConvolve tests");
@@ -111,4 +148,27 @@
     }
 
+    {
+        // FFT mask convolution: 5 tests
+        psMemId id = psMemGetId();
+
+        psImage *mask = generateMask();
+
+        psImage *convolved = psImageConvolveMaskFFT(NULL, mask, MASK_INITIAL, MASK_FINAL,
+                                                    -KERNEL_SIZE, KERNEL_SIZE, -KERNEL_SIZE, KERNEL_SIZE,
+                                                    0.5);
+        ok(convolved, "convolution result");
+        skip_start(!convolved, 3, "convolution failed");
+        ok(convolved->type.type == PS_TYPE_MASK, "output type");
+        ok(convolved->numCols == IMAGE_SIZE && convolved->numRows == IMAGE_SIZE, "output size %dx%d",
+           convolved->numCols, convolved->numRows);
+        ok(checkConvolvedMask(convolved), "convolved mask correct");
+        psFree(convolved);
+        skip_end();
+
+        psFree(mask);
+
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
 
     return exit_status();
