Index: /trunk/psLib/src/image/psImage.c
===================================================================
--- /trunk/psLib/src/image/psImage.c	(revision 648)
+++ /trunk/psLib/src/image/psImage.c	(revision 649)
@@ -7,6 +7,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-10 22:37:04 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-12 19:46:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -57,47 +57,91 @@
 psImage *psImageAlloc(int nCols, int nRows, psType type)
 {
-    psImage *image = NULL;
-
-    image = psAlloc(sizeof(psImage));
-    image->type = type;
+    int area = 0;
+    psElemType imageType = 0;
+    psDimen imageDim = 0;
+
+    imageType = type.type;
+    imageDim =  type.dimen;
+    area = nCols*nRows;
+
+    if(imageDim != PS_DIMEN_IMAGE) {
+        psError(__func__, " : Line %d - Image dimensionality not PS_DIMEN_IMAGE=3 . Dimensionality: %d\n",
+                __LINE__, imageDim);
+        return NULL;
+    } else if(area <= 0) {
+        psError(__func__, " : Line %d - Invalid value for number of rows or columns. nRows: %d nCols: %d \n",
+                __LINE__, nRows, nCols);
+        return NULL;
+    }
+
+    psImage *image = (psImage *)psAlloc(sizeof(psImage));
+
+    switch (type.type) {
+    case PS_TYPE_CHAR:
+        image->rows.rows_c = (char **)psAlloc(ny*sizeof(char *));
+        image->rows.rows_c[0] = (char *)psAlloc(area*sizeof(char));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_c[i] = &image->rows.rows_c[0][i*nx];
+        }
+        break;
+    case PS_TYPE_SHORT:
+        image->rows.rows_s = (short **)psAlloc(ny*sizeof(short *));
+        image->rows.rows_s[0] = (short *)psAlloc(area*sizeof(short));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_s[i] = &image->rows.rows_s[0][i*nx];
+        }
+        break;
+    case PS_TYPE_INT:
+        image->rows.rows_i = (int **)psAlloc(ny*sizeof(int *));
+        image->rows.rows_i[0] = (int *)psAlloc(area*sizeof(int));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_i[i] = &image->rows.rows_i[0][i*nx];
+        }
+        break;
+    case PS_TYPE_LONG:
+        image->rows.rows_l = (long **)psAlloc(ny*sizeof(long *));
+        image->rows.rows_l[0] = (long *)psAlloc(area*sizeof(long));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_l[i] = &image->rows.rows_l[0][i*nx];
+        }
+        break;
+    case PS_TYPE_UCHAR:
+        image->rows.rows_uc = (unsigned char **)psAlloc(ny*sizeof(unsigned char *));
+        image->rows.rows_uc[0] = (unsigned char *)psAlloc(area*sizeof(unsigned char));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_uc[i] = &image->rows.rows_uc[0][i*nx];
+        }
+        break;
+    case PS_TYPE_USHORT:
+        image->rows.rows_us = (unsigned short **)psAlloc(ny*sizeof(unsigned short *));
+        image->rows.rows_us[0] = (unsigned short *)psAlloc(area*sizeof(unsigned short));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_us[i] = &image->rows.rows_us[0][i*nx];
+        }
+        break;
+    case PS_TYPE_UINT:
+        image->rows.rows_ui = (unsigned int **)psAlloc(ny*sizeof(unsigned int *));
+        image->rows.rows_ui[0] = (unsigned int *)psAlloc(area*sizeof(unsigned int));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_ui[i] = &image->rows.rows_ui[0][i*nx];
+        }
+        break;
+    case PS_TYPE_ULONG:
+        image->rows.rows_ul = (unsigned long **)psAlloc(ny*sizeof(unsigned long *));
+        image->rows.rows_ul[0] = (unsigned long *)psAlloc(area*sizeof(unsigned long));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_ul[i] = &image->rows.rows_ul[0][i*nx];
+        }
+        break;
+    }
+
+    image->cols0 = 0;
+    image->rows0 = 0;
     image->nCols = nCols;
     image->nRows = nRows;
-    image->col0 = 0;
-    image->row0 = 0;
+    image->type = type;
     image->parent = NULL;
     image->nChildren = 0;
     image->children = NULL;
-
-    switch(type.type) {
-    case PS_TYPE_SHORT:
-        image->rows.rows_s = psAlloc(nCols*nRows*sizeof(short));
-        break;
-    case PS_TYPE_INT:
-        image->rows.rows_i = psAlloc(nCols*nRows*sizeof(int));
-        break;
-    case PS_TYPE_LONG:
-        image->rows.rows_l = psAlloc(nCols*nRows*sizeof(long));
-        break;
-    case PS_TYPE_USHORT:
-        image->rows.rows_us = psAlloc(nCols*nRows*sizeof(unsigned short));
-        break;
-    case PS_TYPE_UINT:
-        image->rows.rows_ui = psAlloc(nCols*nRows*sizeof(unsigned int));
-        break;
-    case PS_TYPE_ULONG:
-        image->rows.rows_ul = psAlloc(nCols*nRows*sizeof(unsigned long));
-        break;
-    case PS_TYPE_FLOAT:
-        image->rows.rows_f = psAlloc(nCols*nRows*sizeof(float));
-        break;
-    case PS_TYPE_DOUBLE:
-        image->rows.rows_d = psAlloc(nCols*nRows*sizeof(double));
-        break;
-    case PS_TYPE_COMPLEX:
-        image->rows.rows_cf = psAlloc(nCols*nRows*sizeof(complex float));
-        break;
-    default:
-        psError(__func__, " : Line %d - Invalid psImage type: %d\n", __LINE__, type.type);
-    }
 
     return image;
Index: /trunk/psLib/src/image/psImage.h
===================================================================
--- /trunk/psLib/src/image/psImage.h	(revision 648)
+++ /trunk/psLib/src/image/psImage.h	(revision 649)
@@ -7,6 +7,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-10 20:20:42 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-12 19:46:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -40,14 +40,17 @@
     int col0;                       ///< Row position relative to parent.
     int row0;                       ///< Column position relative to parent.
+
     union {
-        short **rows_s;             ///< Pointers to short integer data.
-        int **rows_i;               ///< Pointers to integer data.
-        long **rows_l ;             ///< Pointers to long integer data.
-        unsigned short **rows_us;   ///< Pointers to unsigned short integer data.
-        unsigned int **rows_ui;     ///< Pointers to unsigned integer data.
-        unsigned long **rows_ul;    ///< Pointers to unsigned long integer data.
-        float **rows_f;             ///< Pointers to floating point data.
-        double **rows_d;            ///< Pointers to double precision data.
-        complex float **rows_cf;    ///< Pointers to complex floating point data.
+        char **rowsC                ///< Pointers to char integer data.
+        short **rowsS;              ///< Pointers to short integer data.
+        int **rowsI;                ///< Pointers to integer data.
+        long **rowsL ;              ///< Pointers to long integer data.
+        unsigned char **rowsUC;    ///< Pointers to unsigned char integer data.
+        unsigned short **rowsUS;    ///< Pointers to unsigned short integer data.
+        unsigned int **rowsUI;      ///< Pointers to unsigned integer data.
+        unsigned long **rowsUL;     ///< Pointers to unsigned long integer data.
+        float **rowsF;              ///< Pointers to floating point data.
+        double **rowsD;             ///< Pointers to double precision data.
+        complex float **rowsCF;     ///< Pointers to complex floating point data.
     } rows;                         ///< Union for data types.
     struct psImage *parent;         ///< Parent, if a subimage.
Index: /trunk/psLib/src/mathtypes/psImage.c
===================================================================
--- /trunk/psLib/src/mathtypes/psImage.c	(revision 648)
+++ /trunk/psLib/src/mathtypes/psImage.c	(revision 649)
@@ -7,6 +7,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-10 22:37:04 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-12 19:46:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -57,47 +57,91 @@
 psImage *psImageAlloc(int nCols, int nRows, psType type)
 {
-    psImage *image = NULL;
-
-    image = psAlloc(sizeof(psImage));
-    image->type = type;
+    int area = 0;
+    psElemType imageType = 0;
+    psDimen imageDim = 0;
+
+    imageType = type.type;
+    imageDim =  type.dimen;
+    area = nCols*nRows;
+
+    if(imageDim != PS_DIMEN_IMAGE) {
+        psError(__func__, " : Line %d - Image dimensionality not PS_DIMEN_IMAGE=3 . Dimensionality: %d\n",
+                __LINE__, imageDim);
+        return NULL;
+    } else if(area <= 0) {
+        psError(__func__, " : Line %d - Invalid value for number of rows or columns. nRows: %d nCols: %d \n",
+                __LINE__, nRows, nCols);
+        return NULL;
+    }
+
+    psImage *image = (psImage *)psAlloc(sizeof(psImage));
+
+    switch (type.type) {
+    case PS_TYPE_CHAR:
+        image->rows.rows_c = (char **)psAlloc(ny*sizeof(char *));
+        image->rows.rows_c[0] = (char *)psAlloc(area*sizeof(char));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_c[i] = &image->rows.rows_c[0][i*nx];
+        }
+        break;
+    case PS_TYPE_SHORT:
+        image->rows.rows_s = (short **)psAlloc(ny*sizeof(short *));
+        image->rows.rows_s[0] = (short *)psAlloc(area*sizeof(short));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_s[i] = &image->rows.rows_s[0][i*nx];
+        }
+        break;
+    case PS_TYPE_INT:
+        image->rows.rows_i = (int **)psAlloc(ny*sizeof(int *));
+        image->rows.rows_i[0] = (int *)psAlloc(area*sizeof(int));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_i[i] = &image->rows.rows_i[0][i*nx];
+        }
+        break;
+    case PS_TYPE_LONG:
+        image->rows.rows_l = (long **)psAlloc(ny*sizeof(long *));
+        image->rows.rows_l[0] = (long *)psAlloc(area*sizeof(long));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_l[i] = &image->rows.rows_l[0][i*nx];
+        }
+        break;
+    case PS_TYPE_UCHAR:
+        image->rows.rows_uc = (unsigned char **)psAlloc(ny*sizeof(unsigned char *));
+        image->rows.rows_uc[0] = (unsigned char *)psAlloc(area*sizeof(unsigned char));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_uc[i] = &image->rows.rows_uc[0][i*nx];
+        }
+        break;
+    case PS_TYPE_USHORT:
+        image->rows.rows_us = (unsigned short **)psAlloc(ny*sizeof(unsigned short *));
+        image->rows.rows_us[0] = (unsigned short *)psAlloc(area*sizeof(unsigned short));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_us[i] = &image->rows.rows_us[0][i*nx];
+        }
+        break;
+    case PS_TYPE_UINT:
+        image->rows.rows_ui = (unsigned int **)psAlloc(ny*sizeof(unsigned int *));
+        image->rows.rows_ui[0] = (unsigned int *)psAlloc(area*sizeof(unsigned int));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_ui[i] = &image->rows.rows_ui[0][i*nx];
+        }
+        break;
+    case PS_TYPE_ULONG:
+        image->rows.rows_ul = (unsigned long **)psAlloc(ny*sizeof(unsigned long *));
+        image->rows.rows_ul[0] = (unsigned long *)psAlloc(area*sizeof(unsigned long));
+        for(int i = 1; i < ny; i++) {
+            image->rows.rows_ul[i] = &image->rows.rows_ul[0][i*nx];
+        }
+        break;
+    }
+
+    image->cols0 = 0;
+    image->rows0 = 0;
     image->nCols = nCols;
     image->nRows = nRows;
-    image->col0 = 0;
-    image->row0 = 0;
+    image->type = type;
     image->parent = NULL;
     image->nChildren = 0;
     image->children = NULL;
-
-    switch(type.type) {
-    case PS_TYPE_SHORT:
-        image->rows.rows_s = psAlloc(nCols*nRows*sizeof(short));
-        break;
-    case PS_TYPE_INT:
-        image->rows.rows_i = psAlloc(nCols*nRows*sizeof(int));
-        break;
-    case PS_TYPE_LONG:
-        image->rows.rows_l = psAlloc(nCols*nRows*sizeof(long));
-        break;
-    case PS_TYPE_USHORT:
-        image->rows.rows_us = psAlloc(nCols*nRows*sizeof(unsigned short));
-        break;
-    case PS_TYPE_UINT:
-        image->rows.rows_ui = psAlloc(nCols*nRows*sizeof(unsigned int));
-        break;
-    case PS_TYPE_ULONG:
-        image->rows.rows_ul = psAlloc(nCols*nRows*sizeof(unsigned long));
-        break;
-    case PS_TYPE_FLOAT:
-        image->rows.rows_f = psAlloc(nCols*nRows*sizeof(float));
-        break;
-    case PS_TYPE_DOUBLE:
-        image->rows.rows_d = psAlloc(nCols*nRows*sizeof(double));
-        break;
-    case PS_TYPE_COMPLEX:
-        image->rows.rows_cf = psAlloc(nCols*nRows*sizeof(complex float));
-        break;
-    default:
-        psError(__func__, " : Line %d - Invalid psImage type: %d\n", __LINE__, type.type);
-    }
 
     return image;
Index: /trunk/psLib/src/mathtypes/psImage.h
===================================================================
--- /trunk/psLib/src/mathtypes/psImage.h	(revision 648)
+++ /trunk/psLib/src/mathtypes/psImage.h	(revision 649)
@@ -7,6 +7,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-10 20:20:42 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-12 19:46:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -40,14 +40,17 @@
     int col0;                       ///< Row position relative to parent.
     int row0;                       ///< Column position relative to parent.
+
     union {
-        short **rows_s;             ///< Pointers to short integer data.
-        int **rows_i;               ///< Pointers to integer data.
-        long **rows_l ;             ///< Pointers to long integer data.
-        unsigned short **rows_us;   ///< Pointers to unsigned short integer data.
-        unsigned int **rows_ui;     ///< Pointers to unsigned integer data.
-        unsigned long **rows_ul;    ///< Pointers to unsigned long integer data.
-        float **rows_f;             ///< Pointers to floating point data.
-        double **rows_d;            ///< Pointers to double precision data.
-        complex float **rows_cf;    ///< Pointers to complex floating point data.
+        char **rowsC                ///< Pointers to char integer data.
+        short **rowsS;              ///< Pointers to short integer data.
+        int **rowsI;                ///< Pointers to integer data.
+        long **rowsL ;              ///< Pointers to long integer data.
+        unsigned char **rowsUC;    ///< Pointers to unsigned char integer data.
+        unsigned short **rowsUS;    ///< Pointers to unsigned short integer data.
+        unsigned int **rowsUI;      ///< Pointers to unsigned integer data.
+        unsigned long **rowsUL;     ///< Pointers to unsigned long integer data.
+        float **rowsF;              ///< Pointers to floating point data.
+        double **rowsD;             ///< Pointers to double precision data.
+        complex float **rowsCF;     ///< Pointers to complex floating point data.
     } rows;                         ///< Union for data types.
     struct psImage *parent;         ///< Parent, if a subimage.
