Index: /trunk/psLib/test/image/tst_psImageManip.c
===================================================================
--- /trunk/psLib/test/image/tst_psImageManip.c	(revision 1653)
+++ /trunk/psLib/test/image/tst_psImageManip.c	(revision 1654)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-20 02:55:42 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-28 01:19:26 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -31,4 +31,6 @@
 static int testImageRoll(void);
 static int testImageRotate(void);
+static int testImageShift(void);
+static int testImageShiftCase(int cols, int rows, float colShift,float rowShift);
 
 testDescription tests[] = {
@@ -53,4 +55,7 @@
                               {
                                   testImageRotate,560,"psImageRotate",0,false
+                              },
+                              {
+                                  testImageShift,561,"psImageShift",0,false
                               },
                               {
@@ -1238,2 +1243,139 @@
     return 0;
 }
+
+static int testImageShift(void)
+{
+    /* psImageShift:
+
+       This functions shall generate a new psImage structure by shifting the 
+       input psImage structure a specified number of pixels in the horizontal 
+       and/or vertical directions.
+
+       Verify the returned psImage structure contains expected values, if the 
+       input psImage structure contains known values and a know shift in the 
+       vertical and/or horizontal directions. Cases should include no shift, 
+       vertical only(up,down), horizontal only(right, left), and combination 
+       shift. Cases should include fractional shifts. Comparison of expected 
+       values should include a delta to allow for testing on different 
+       platforms.
+
+       Verify the returned psImage structure contains values for pixels not in 
+       the original image set to the input parameter exposed.
+
+    */
+
+    int retVal;
+
+    // integer shift
+    retVal |= testImageShiftCase(64,128,0.0f,0.0f);
+    retVal |= testImageShiftCase(64,128,0.0f,16.0f);
+    retVal |= testImageShiftCase(64,128,0.0f,-16.0f);
+    retVal |= testImageShiftCase(64,128,32.0f,0.0f);
+    retVal |= testImageShiftCase(64,128,-32.0f,0.0f);
+    retVal |= testImageShiftCase(64,128,32.0f,16.0f);
+    retVal |= testImageShiftCase(64,128,32.0f,-16.0f);
+    retVal |= testImageShiftCase(64,128,-32.0f,16.0f);
+    retVal |= testImageShiftCase(64,128,-32.0f,-16.0f);
+
+    if (retVal != 0) {
+        return retVal;
+    }
+
+    // fractional shift
+    retVal |= testImageShiftCase(64,128,0.0f,16.4f);
+    retVal |= testImageShiftCase(64,128,0.0f,-16.4f);
+    retVal |= testImageShiftCase(64,128,32.7f,0.0f);
+    retVal |= testImageShiftCase(64,128,-32.7f,0.0f);
+    retVal |= testImageShiftCase(64,128,32.6f,16.2f);
+    retVal |= testImageShiftCase(64,128,32.6f,-16.2f);
+    retVal |= testImageShiftCase(64,128,-32.6f,16.2f);
+    retVal |= testImageShiftCase(64,128,-32.6f,-16.2f);
+
+    if (retVal != 0) {
+        return retVal;
+    }
+
+    /*
+       Verify the returned psImage structure pointer is equal to the input 
+       parameter out if provided.
+    */
+    psImage* fImg = psImageAlloc(32,32,PS_TYPE_F32);
+    psImage* fRecycle = psImageAlloc(32,32,PS_TYPE_F32);
+    psImage* fOut = psImageShift(fRecycle, fImg, 8,8, NAN, PS_INTERPOLATE_FLAT);
+
+    if (fRecycle != fOut) {
+        psError(__func__,"psImageShift didn't recycle my image?");
+        return 10;
+    }
+
+    /*
+       Verify the returned psImage structure pointer is null and program 
+       execution doesn't stop, if the input psImage structure pointer is null.
+    */
+    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error...");
+    fOut = psImageShift(fOut,NULL,8,8,NAN,PS_INTERPOLATE_FLAT);
+    if (fOut != NULL) {
+        psError(__func__,"psImageShift didn't return NULL given a NULL input image.");
+        return 11;
+    }
+
+    psFree(fImg);
+
+    return 0;
+}
+
+static int testImageShiftCase(int cols,
+                              int rows,
+                              float colShift,
+                              float rowShift)
+{
+    psImage* fOut = NULL;
+    psImage* sOut = NULL;
+
+    psLogMsg(__func__,PS_LOG_INFO,"Testing psImageShift with a %dx%d image for "
+             "a shift of %g,%g.",cols,rows,colShift,rowShift);
+
+    psImage* fImg = psImageAlloc(cols,rows,PS_TYPE_F32);
+    psImage* sImg = psImageAlloc(cols,rows,PS_TYPE_S16);
+
+    for(int row=0;row<rows;row++) {
+        psF32* fRow = fImg->data.F32[row];
+        psS16* sRow = sImg->data.S16[row];
+        for (int col=0;col<cols;col++) {
+            fRow[col] = (psF32)(row)+(psF32)(col)/100.0f;
+            sRow[col] = row-2*col;
+        }
+    }
+
+    fOut = psImageShift(fOut, fImg, colShift, rowShift, NAN, PS_INTERPOLATE_FLAT);
+    sOut = psImageShift(sOut, sImg, colShift, rowShift, -1, PS_INTERPOLATE_FLAT);
+
+    for(int row=0;row<rows;row++) {
+        psF32* fRow = fOut->data.F32[row];
+        psS16* sRow = sOut->data.S16[row];
+        for (int col=0;col<cols;col++) {
+            psF32 fValue = psImagePixelInterpolate(fImg,col+colShift,
+                                                   row+rowShift,NAN,PS_INTERPOLATE_FLAT);
+            psS16 sValue = (psS16)psImagePixelInterpolate(sImg,col+colShift,
+                           row+rowShift,-1,PS_INTERPOLATE_FLAT);
+
+            if (fabsf(fRow[col] - fValue) > FLT_EPSILON) {
+                psError(__func__,"Float image not shifted correctly at %d,%d (%g vs %g)",
+                        col,row,fRow[col],fValue);
+                return 1;
+            }
+            if (sRow[col] != sValue) {
+                psError(__func__,"Short image not shifted correctly at %d,%d (%d vs %d)",
+                        col,row,sRow[col],sValue);
+                return 2;
+            }
+        }
+    }
+
+    psFree(fImg);
+    psFree(sImg);
+    psFree(fOut);
+    psFree(sOut);
+
+    return 0;
+}
Index: /trunk/psLib/test/image/verified/tst_psImageManip.stderr
===================================================================
--- /trunk/psLib/test/image/verified/tst_psImageManip.stderr	(revision 1653)
+++ /trunk/psLib/test/image/verified/tst_psImageManip.stderr	(revision 1654)
@@ -124,2 +124,30 @@
 ---> TESTPOINT PASSED (psImage{psImageRotate} | tst_psImageManip.c)
 
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psImageManip.c                                         *
+*            TestPoint: psImage{psImageShift}                                      *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 0,0.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 0,16.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 0,-16.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 32,0.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of -32,0.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 32,16.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 32,-16.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of -32,16.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of -32,-16.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 0,16.4.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 0,-16.4.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 32.7,0.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of -32.7,0.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 32.6,16.2.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 32.6,-16.2.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of -32.6,16.2.
+<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of -32.6,-16.2.
+<DATE><TIME>|<HOST>|I| testImageShift|Following should be an error...
+<DATE><TIME>|<HOST>|E|   psImageShift|Input image can not be NULL.
+
+---> TESTPOINT PASSED (psImage{psImageShift} | tst_psImageManip.c)
+
