Index: /trunk/psLib/src/image/psImageManip.c
===================================================================
--- /trunk/psLib/src/image/psImageManip.c	(revision 3934)
+++ /trunk/psLib/src/image/psImageManip.c	(revision 3935)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-05-12 00:54:49 $
+ *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-05-14 00:16:46 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -1079,12 +1079,61 @@
     }
 
-    // find the input image domain in the output image
+    int row0 = region.y0;
+    int row1 = region.y1;
+    int col0 = region.x0;
+    int col1 = region.x1;
+    if (col1 < 1) {
+        col1 += input->numCols;
+    }
+
+    if (row1 < 1) {
+        row1 += input->numRows;
+    }
+
+    int numRows = row1 - row0;
+    int numCols = col1 - col0;
+
+    if (numRows < 1 || numCols < 1) {
+        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                "The specified region is invalid.");
+        psFree(output);
+        return NULL;
+    }
+
+    // create the output image.
+    output = psImageRecycle(output, numCols, numRows, input->type.type);
+    *(psS32*)&output->col0 = region.x0;
+    *(psS32*)&output->row0 = region.y0;
+
 
     // loop through the output image using the domain above and transform
     // each output pixel to input coordinates and use psImagePixelInterpolate
     // to determine the pixel value.
-
-
-    return NULL;
+    psPlane outPosition;
+    psPlane* inPosition = NULL;
+    for (int row = 0; row < numRows; row++) {
+        outPosition.y = row+row0;
+        psF32* outputData=output->data.F32[row];
+        for (int col = 0; col < numCols; col++) {
+            outPosition.x = col+col0;
+            // apply the transform to get the position in the input image
+            inPosition = psPlaneTransformApply(inPosition, outToIn, inPosition);
+
+            if (inPosition == NULL) {
+                psError(PS_ERR_UNKNOWN, false,
+                        "Failed to apply the transform");
+                psFree(output);
+                return NULL;
+            }
+            // interpolate the cooresponding input pixel to get the output pixel value.
+            outputData[col] = (psF32)psImagePixelInterpolate(input,
+                              inPosition->x, inPosition->y,
+                              inputMask, inputMaskVal, exposedValue,
+                              mode);
+
+        }
+    }
+
+    return output;
 }
 
