Index: trunk/psLib/src/image/psImageExtraction.c
===================================================================
--- trunk/psLib/src/image/psImageExtraction.c	(revision 1897)
+++ trunk/psLib/src/image/psImageExtraction.c	(revision 1918)
@@ -10,6 +10,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-09-25 02:06:12 $
+*  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-09-28 02:27:58 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -26,8 +26,8 @@
 
 psImage* psImageSubset(psImage* image,
-                       unsigned int numCols,
-                       unsigned int numRows,
-                       unsigned int col0,
-                       unsigned int row0)
+                       int col0,
+                       int row0,
+                       int col1,
+                       int row1)
 {
     psImage* out;
@@ -49,23 +49,26 @@
     }
 
-    if (numCols < 1 || numRows < 1) {
-        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubset",
-                   PS_ERR_BAD_PARAMETER_VALUE, true,
-                   PS_ERRORTEXT_psImage_AREA_NEGATIVE,
-                   numCols,numRows);
-        return NULL;
-    }
-
-    if ( col0 >= image->numCols ||
+    if (col1 < 1) {
+        col1 = image->numCols + col1;
+    }
+    if (row1 < 1) {
+        row1 = image->numRows + row1;
+    }
+
+    if (    col1 <= col0 ||
+            row1 <= row0 ||
+            col0 >= image->numCols ||
             row0 >= image->numRows ||
-            col0 + numCols >= image->numCols ||
-            row0 + numRows >= image->numRows ) {
+            col1 > image->numCols ||
+            row1 > image->numRows ) {
         psErrorMsg(PS_ERRORNAME_DOMAIN "psImageSubset",
                    PS_ERR_BAD_PARAMETER_VALUE, true,
                    PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
-                   col0, col0 + numCols, row0, row0 + numRows,
+                   col0, col1, row0, row1,
                    image->numCols, image->numRows);
         return NULL;
     }
+    int numRows = row1-row0;
+    int numCols = col1-row0;
 
     elementSize = PSELEMTYPE_SIZEOF(image->type.type);
@@ -123,5 +126,5 @@
         return NULL;
     }
-    return psImageSubset(image,x2-x1+1,y2-y1+1,x1,y1);
+    return psImageSubset(image,x1,y1,x2,y2);
 }
 
