Index: trunk/psLib/src/imageops/psImageGeomManip.c
===================================================================
--- trunk/psLib/src/imageops/psImageGeomManip.c	(revision 9865)
+++ trunk/psLib/src/imageops/psImageGeomManip.c	(revision 9927)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-11-06 02:02:59 $
+ *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-11-09 20:20:27 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -594,4 +594,90 @@
 }
 
+// XXX this function seems to work (except for edge pixels and masked pixels
+// but the function below does not define the right 3x3 kernels.  look this
+// up
+psImage *p_psImageShiftKernel_F32(
+    psImage *out,
+    const psImage *input,
+    const psImage *kernel)
+{
+
+    PS_ASSERT_IMAGE_NON_NULL(input, NULL);
+    PS_ASSERT_IMAGE_NON_NULL(kernel, NULL);
+
+    if ((kernel->numCols % 2 == 0) || (kernel->numRows % 2 == 0)) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                _("kernel must have odd dimensions"));
+        return NULL;
+    }
+    int Xk = (kernel->numCols - 1) / 2;
+    int Yk = (kernel->numRows - 1) / 2;
+
+    int outRows = input->numRows;
+    int outCols = input->numCols;
+    out = psImageRecycle(out, outCols, outRows, input->type.type);
+    psImageInit (out, 0.0);
+
+    // need to handle the edge cases...
+    for (int row = 1; row < outRows-1; row++) {
+        psF32 *outRow = out->data.F32[row];
+        psF32 **inValue = input->data.F32;
+        for (int col = 1; col < outCols-1; col++) {
+            double value = 0;
+            double norm = 0;
+            psF32 **kernValue = kernel->data.F32;
+            for (int yi = -Yk; yi <= Yk; yi++) {
+                for (int xi = -Xk; xi <= Xk; xi++) {
+                    value += inValue[row+yi][col+xi]*kernValue[yi+Yk][xi+Xk];
+                    norm += kernValue[yi+Yk][xi+Xk];
+                }
+            }
+            // include the mask tests and divide-by-zero test
+            outRow[col] = value / norm;
+        }
+    }
+
+    return (out);
+}
+
+// XXX fix the definition of the interpolation kernels and add integer shifts
+psImage *psImageShiftKernel (
+    psImage *out,
+    const psImage *input,
+    float dx, float dy, psImageInterpolateMode mode)
+{
+
+    psImage *kernel = NULL;
+
+    switch (mode) {
+    case PS_INTERPOLATE_BICUBE:
+        kernel = psImageAlloc (3, 3, PS_TYPE_F32);
+        for (int iy = -1; iy <= +1; iy++) {
+            for (int ix = -1; ix <= +1; ix++) {
+                kernel->data.F32[iy+1][ix+1] = 5 - 3*PS_SQR(ix+dx) - 3*PS_SQR(iy+dy);
+            }
+        }
+        out = p_psImageShiftKernel_F32 (out, input, kernel);
+        break;
+
+    case PS_INTERPOLATE_GAUSS:
+        kernel = psImageAlloc (3, 3, PS_TYPE_F32);
+        for (int iy = -1; iy <= +1; iy++) {
+            for (int ix = -1; ix <= +1; ix++) {
+                kernel->data.F32[iy+1][ix+1] = exp(-0.5*PS_SQR(ix+dx) -0.5*PS_SQR(iy+dy));
+            }
+        }
+        out = p_psImageShiftKernel_F32 (out, input, kernel);
+        break;
+
+    default:
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                _("shift kernel for %d not defined"), mode);
+        return NULL;
+    }
+    psFree (kernel);
+    return (out);
+}
+
 psImage* psImageShift(psImage* out,
                       const psImage* input,
