Index: /trunk/psLib/src/imageops/psImageGeomManip.c
===================================================================
--- /trunk/psLib/src/imageops/psImageGeomManip.c	(revision 6805)
+++ /trunk/psLib/src/imageops/psImageGeomManip.c	(revision 6806)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-04-05 01:49:40 $
+ *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-04-06 22:55:18 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -753,6 +753,6 @@
             row0 = input->row0;
             col0 = input->col0;
-            row1 = input->row0 + input->numRows;
-            col1 = input->col0 + input->numCols;
+            row1 = input->row0 + input->numRows - 1;
+            col1 = input->col0 + input->numCols - 1;
         }
         if (col1 < 1) {
@@ -782,6 +782,6 @@
         row0 = output->row0;
         col0 = output->col0;
-        row1 = row0+numRows;
-        col1 = col0+numCols;
+        row1 = row0+numRows -1;
+        col1 = col0+numCols -1;
     }
 
Index: /trunk/psLib/src/imageops/psImagePixelExtract.c
===================================================================
--- /trunk/psLib/src/imageops/psImagePixelExtract.c	(revision 6805)
+++ /trunk/psLib/src/imageops/psImagePixelExtract.c	(revision 6806)
@@ -8,6 +8,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-04-06 04:12:27 $
+ *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-04-06 22:55:18 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -334,4 +334,12 @@
     }
 
+    //If [0,0,0,0] specified, the whole image is to be included
+    if (row0 == 0 && col0 == 0 && row1 == 0 && col1 == 0) {
+        row0 = input->row0;
+        col0 = input->col0;
+        row1 = input->row0 + input->numRows - 1;
+        col1 = input->col0 + input->numCols - 1;
+    }
+
     //Make sure x0 of region is inside image.  If so, set col0 to corresponding index number.
     if (col0 >= input->col0 && col0 < (input->col0 + input->numCols) ) {
@@ -341,4 +349,5 @@
                 "Specified psRegion parameter, x0=%f, is out of range [%d,%d].\n",
                 region.x0, input->col0, input->col0+input->numCols-1);
+        psFree(out);
         return NULL;
     }
@@ -350,13 +359,6 @@
                 "Specified psRegion parameter, y0=%f, is out of range [%d,%d].\n",
                 region.y0, input->row0, input->row0+input->numRows-1);
-        return NULL;
-    }
-
-    //If [0,0,0,0] specified, the whole image is to be included
-    if (row0 == 0 && col0 == 0 && row1 == 0 && col1 == 0) {
-        row0 = input->row0;
-        col0 = input->col0;
-        row1 = input->row0 + input->numRows;
-        col1 = input->col0 + input->numCols;
+        psFree(out);
+        return NULL;
     }
 
@@ -368,4 +370,5 @@
                     "Specified psRegion parameter, x1=%f=%d, is out of range [%d,%d].\n",
                     region.x1, col1+input->col0, input->col0, input->col0+input->numCols-1);
+            psFree(out);
             return NULL;
         }
@@ -376,4 +379,5 @@
                 "Specified psRegion parameter, x1=%f=%d, is out of range [%d,%d].\n",
                 region.x1, col1, input->col0, input->col0+input->numCols-1);
+        psFree(out);
         return NULL;
     }
@@ -385,4 +389,5 @@
                     "Specified psRegion parameter, y1=%f=%d, is out of range [%d,%d].\n",
                     region.y1, row1+input->row0, input->row0, input->row0+input->numRows-1);
+            psFree(out);
             return NULL;
         }
@@ -393,4 +398,5 @@
                 "Specified psRegion parameter, y1=%f=%d, is out of range [%d,%d].\n",
                 region.y1, row1, input->row0, input->row0+input->numRows-1);
+        psFree(out);
         return NULL;
     }
@@ -406,8 +412,10 @@
                     region.y0, row0, region.y1, row1);
         }
+        psFree(out);
         return NULL;
     } else if (col0 == col1 && row0 == row1) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
                 "Invalid psRegion specified.  Region contains only 1 pixel.\n");
+        psFree(out);
         return NULL;
     }
@@ -679,6 +687,6 @@
         row0 = input->row0;
         col0 = input->col0;
-        row1 = input->row0 + input->numRows;
-        col1 = input->col0 + input->numCols;
+        row1 = input->row0 + input->numRows - 1;
+        col1 = input->col0 + input->numCols - 1;
     }
 
Index: /trunk/psLib/test/imageops/tst_psImagePixelExtract.c
===================================================================
--- /trunk/psLib/test/imageops/tst_psImagePixelExtract.c	(revision 6805)
+++ /trunk/psLib/test/imageops/tst_psImagePixelExtract.c	(revision 6806)
@@ -6,6 +6,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-04-05 01:49:41 $
+*  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-04-06 22:55:18 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -341,4 +341,115 @@
     }
 
+    //Added tests after subimage changes.
+    psFree(image);
+    image = psImageAlloc( c, r, PS_TYPE_F64 );
+    for ( psS32 row = 0;row < r;row++ ) {
+        psF64 *imageRow = image->data.F64[ row ];
+        psF64 rowOffset = row * 2;
+        for ( psS32 col = 0;col < c;col++ ) {
+            imageRow[ col ] = col + rowOffset;
+        }
+    }
+    image->col0 = 1;
+    image->row0 = 1;
+    psFree(out);
+    out = NULL;
+    out = psImageSlice(out,positions,image,mask,1,
+                       psRegionSet(1,c,1,r),PS_CUT_X_POS,stat);
+    if (out == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, false,
+                "psImageSlice failed to return the correct psVector.  Got NULL instead.\n");
+        return 112;
+    }
+    psFree(out);
+    out = NULL;
+    //Return NULL for incorrect image inputs.
+    image->row0 = -1;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
+    out = psImageSlice(out,positions,image,mask,1,
+                       psRegionSet(1,c,1,r),PS_CUT_X_POS,stat);
+    if (out != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psImageSlice failed to return NULL for invalid specified input.\n");
+        return 113;
+    }
+    image->col0 = -1;
+    image->row0 = 1;
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
+    out = psImageSlice(out,positions,image,mask,1,
+                       psRegionSet(1,c,1,r),PS_CUT_X_POS,stat);
+    if (out != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psImageSlice failed to return NULL for invalid specified input.\n");
+        return 114;
+    }
+    image->col0 = 1;
+    //Return NULL for incorrect region inputs.
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
+    out = psImageSlice(out,positions,image,mask,1,
+                       psRegionSet(0,c,1,r),PS_CUT_X_POS,stat);
+    if (out != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psImageSlice failed to return NULL for invalid specified input.\n");
+        return 115;
+    }
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
+    out = psImageSlice(out,positions,image,mask,1,
+                       psRegionSet(1,c,1,r+1),PS_CUT_X_POS,stat);
+    if (out != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psImageSlice failed to return NULL for invalid specified input.\n");
+        return 116;
+    }
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
+    out = psImageSlice(out,positions,image,mask,1,
+                       psRegionSet(1,c,1,-r-2),PS_CUT_X_POS,stat);
+    if (out != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psImageSlice failed to return NULL for invalid specified input.\n");
+        return 117;
+    }
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
+    out = psImageSlice(out,positions,image,mask,1,
+                       psRegionSet(c,1,1,r),PS_CUT_X_POS,stat);
+    if (out != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psImageSlice failed to return NULL for invalid specified input.\n");
+        return 118;
+    }
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
+    out = psImageSlice(out,positions,image,mask,1,
+                       psRegionSet(1,1,1,1),PS_CUT_X_POS,stat);
+    if (out != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psImageSlice failed to return NULL for invalid specified input.\n");
+        return 119;
+    }
+
+    //Make sure that regions match appropriately...
+    out = psImageSlice(out,positions,image,mask,1,
+                       psRegionSet(1,-1,1,-1),PS_CUT_Y_NEG,stat);
+    psVector *out2 = NULL;
+    out2 = psImageSlice(out2,positions,image,mask,1,
+                        psRegionSet(0,0,0,0),PS_CUT_Y_NEG,stat);
+    if (out == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, false,
+                "psImageSlice incorrectly returned NULL for valid inputs.\n");
+        return 120;
+    } else if (out2 == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, false,
+                "psImageSlice incorrectly returned NULL for valid inputs.\n");
+        return 121;
+    } else if (out->n != out2->n) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psImageSlice failed to return matching vectors for equivalent inputs.\n");
+        return 122;
+    } else if (out->data.F64[out->n-1] != out2->data.F64[out2->n-1] ) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psImageSlice failed to return matching vectors for equivalent inputs.\n");
+        return 123;
+    }
+    psFree(out2);
+
     psFree( image );
     psFree( positions );
Index: /trunk/psLib/test/imageops/verified/tst_psImagePixelExtract.stderr
===================================================================
--- /trunk/psLib/test/imageops/verified/tst_psImagePixelExtract.stderr	(revision 6805)
+++ /trunk/psLib/test/imageops/verified/tst_psImagePixelExtract.stderr	(revision 6806)
@@ -49,4 +49,32 @@
 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
     Input psImage mask type, psS8, is not the supported mask datatype of psU8.
+<DATE><TIME>|<HOST>|I|testImageSlice
+    Following should generate error message
+<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
+    psImage input is invalid.  row0 cannot be negative.
+<DATE><TIME>|<HOST>|I|testImageSlice
+    Following should generate error message
+<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
+    psImage input is invalid.  col0 cannot be negative.
+<DATE><TIME>|<HOST>|I|testImageSlice
+    Following should generate error message
+<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
+    Specified psRegion parameter, x0=0.000000, is out of range [1,300].
+<DATE><TIME>|<HOST>|I|testImageSlice
+    Following should generate error message
+<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
+    Specified psRegion parameter, y1=201.000000=201, is out of range [1,200].
+<DATE><TIME>|<HOST>|I|testImageSlice
+    Following should generate error message
+<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
+    Specified psRegion parameter, y1=-202.000000=-1, is out of range [1,200].
+<DATE><TIME>|<HOST>|I|testImageSlice
+    Following should generate error message
+<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
+    Invalid psRegion specified.  x0=300.000000=299 is greater than x1=1.000000=0.
+<DATE><TIME>|<HOST>|I|testImageSlice
+    Following should generate error message
+<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
+    Invalid psRegion specified.  Region contains only 1 pixel.
 
 ---> TESTPOINT PASSED (psImage{psImageSlice} | tst_psImagePixelExtract.c)
