Index: trunk/psLib/src/collections/psCollectionsErrors.dat
===================================================================
--- trunk/psLib/src/collections/psCollectionsErrors.dat	(revision 4209)
+++ trunk/psLib/src/collections/psCollectionsErrors.dat	(revision 4212)
@@ -16,4 +16,6 @@
 psVector_SORT_NULL                     psVectorSort can not sort a NULL psVector.
 psVector_UNSUPPORTED_TYPE              Input psVector is an unsupported type (0x%x).
+psVector_NULL                          The input psVector can not be NULL.
+psVector_EXTENDSIZE_NEG                The input number of elements to extend must be non-negative.
 #
 psBitSet_ALLOC_NEG_SIZE                The number of bit in a psBitSet (%d) must be greater than zero.
Index: trunk/psLib/src/collections/psCollectionsErrors.h
===================================================================
--- trunk/psLib/src/collections/psCollectionsErrors.h	(revision 4209)
+++ trunk/psLib/src/collections/psCollectionsErrors.h	(revision 4212)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-08 23:40:45 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-10 21:46:46 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -37,4 +37,6 @@
 #define PS_ERRORTEXT_psVector_SORT_NULL "psVectorSort can not sort a NULL psVector."
 #define PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE "Input psVector is an unsupported type (0x%x)."
+#define PS_ERRORTEXT_psVector_NULL "The input psVector can not be NULL."
+#define PS_ERRORTEXT_psVector_EXTENDSIZE_NEG "The input number of elements to extend must be non-negative."
 #define PS_ERRORTEXT_psBitSet_ALLOC_NEG_SIZE "The number of bit in a psBitSet (%d) must be greater than zero."
 #define PS_ERRORTEXT_psBitSet_SET_NULL "Can not operate on a NULL psBitSet."
Index: trunk/psLib/src/collections/psPixels.c
===================================================================
--- trunk/psLib/src/collections/psPixels.c	(revision 4209)
+++ trunk/psLib/src/collections/psPixels.c	(revision 4212)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-09 23:51:49 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-10 21:46:46 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -132,10 +132,10 @@
 
     // determine the output image size
-    int numRows = x1-x0;
-    int numCols = y1-y0;
+    int numRows = y1-y0;
+    int numCols = x1-x0;
     if (numRows < 1 || numCols < 1) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
                 PS_ERRORTEXT_psPixels_REGION_INVALID,
-                x0,x1,y0,y1);
+                y0,y1,x0,x1);
         psFree(out);
         return NULL;
@@ -150,6 +150,6 @@
         return NULL;
     }
-    *(psS32*)&out->row0 = x0;
-    *(psS32*)&out->col0 = y0;
+    *(psS32*)&out->row0 = y0;
+    *(psS32*)&out->col0 = x0;
 
     // initialize image to all zeros
@@ -169,5 +169,5 @@
         // pixel in region?
         if (x >= x0 && x < x1 && y >= y0 && y < y1) {
-            outData[x-x0][y-y0] |= maskVal;
+            outData[y-y0][x-x0] |= maskVal;
         }
     }
Index: trunk/psLib/src/collections/psVector.c
===================================================================
--- trunk/psLib/src/collections/psVector.c	(revision 4209)
+++ trunk/psLib/src/collections/psVector.c	(revision 4212)
@@ -9,6 +9,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-04-29 02:25:09 $
+*  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-06-10 21:46:46 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -54,4 +54,10 @@
 
     elementSize = PSELEMTYPE_SIZEOF(elemType);
+    if (elementSize < 1) {
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, elemType);
+        return NULL;
+    }
+
 
     // Create vector struct
@@ -121,4 +127,41 @@
     in->n = n;
     return in;
+}
+
+psVector *psVectorExtend(psVector *vector, int delta, int nExtend)
+{
+    // can't handle a NULL vector (don't know the data type to allocate)
+    if (vector == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psVector_NULL);
+        return NULL;
+    }
+
+    // requirement on delta; if < 1, set to 10.
+    if (delta < 1) {
+        delta = 10;
+    }
+
+    // adjust the allocated size, if needed. (if nExtend < 1, this is will never happen)
+    if (nExtend > 0) {
+        unsigned int minAlloc = vector->n + nExtend + nExtend;
+        if (vector->nalloc < minAlloc) {
+            unsigned int nAlloc = delta + vector->nalloc;
+            // make sure the delta is large enough hold twice the extended length.
+            if (nAlloc < minAlloc) {
+                nAlloc = minAlloc;
+            }
+            vector = psVectorRealloc(vector, nAlloc);
+        }
+    } else if (nExtend < -vector->n) {
+        // For the case of a negative nExtend, need to check that we are not decreasing
+        // vector beyond its own length (i.e., creating a negative length).
+        nExtend = -vector->n;
+    }
+
+    // increment the length by the value specified
+    vector->n += nExtend;
+
+    return vector;
 }
 
Index: trunk/psLib/src/collections/psVector.h
===================================================================
--- trunk/psLib/src/collections/psVector.h	(revision 4209)
+++ trunk/psLib/src/collections/psVector.h	(revision 4212)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-08 23:40:45 $
+ *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-06-10 21:46:46 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -88,4 +88,19 @@
     psVector* psVec,                   ///< Vector to reallocate.
     psU32 nalloc                       ///< Total number of elements to make available.
+);
+
+/** Extend a vector's length.
+ *
+ *  Increments a vector's length, n, by the specified number of elements.
+ *  If the allocated storage is less than the current vector's length plus
+ *  twice the number of elements to be added, it is reallocated larger by
+ *  a given amount.
+ *
+ *  @return psVector*      Pointer to the adjusted psVector
+ */
+psVector *psVectorExtend(
+    psVector *vector,                  ///< Vector to extend
+    int delta,                         ///< Amount to expand allocation, if necessary
+    int nExtend                        ///< Number of elements to add to vector length
 );
 
