Index: trunk/psLib/src/image/psImage.c
===================================================================
--- trunk/psLib/src/image/psImage.c	(revision 1406)
+++ trunk/psLib/src/image/psImage.c	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file  psImage.c
  *
@@ -9,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-06 22:34:05 $
+ *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-07 00:06:06 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -18,5 +19,7 @@
 
 /******************************************************************************/
+
 /*  INCLUDE FILES                                                             */
+
 /******************************************************************************/
 
@@ -29,53 +32,61 @@
 #include "psImage.h"
 
-static void imageFree(psImage* image);
+static void imageFree(psImage * image);
 
 /*****************************************************************************/
+
 /* FUNCTION IMPLEMENTATION - PUBLIC                                          */
+
 /*****************************************************************************/
 
-psImage *psImageAlloc(unsigned int numCols, unsigned int numRows,
-                      const psElemType type)
+psImage *psImageAlloc(unsigned int numCols, unsigned int numRows, const psElemType type)
 {
     int area = 0;
-    int elementSize = PSELEMTYPE_SIZEOF(type); // element size in bytes
-    int rowSize = numCols*elementSize;  // row size in bytes.
-
-    area = numCols*numRows;
+    int elementSize = PSELEMTYPE_SIZEOF(type);  // element
+
+    // size in
+    // bytes
+    int rowSize = numCols * elementSize;        // row
+
+    // size
+
+    // in bytes.
+
+    area = numCols * numRows;
 
     if (area < 1) {
-        psError(__func__, "Invalid value for number of rows or columns "
-                "(numRows=%d, numCols=%d).", numRows, numCols);
+        psError(__func__,
+                "Invalid value for number of rows or columns " "(numRows=%d, numCols=%d).", numRows, numCols);
         return NULL;
     }
 
-    psImage *image = (psImage *)psAlloc(sizeof(psImage));
-    if(image == NULL) {
-        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
-    }
-
-    p_psMemSetDeallocator(image,(psFreeFcn)imageFree);
-
-    image->data.V = psAlloc(sizeof(void*)*numRows);
-    if(image->data.V == NULL) {
-        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
-    }
-
-
-    image->data.V[0] = psAlloc(area*elementSize);
-    if(image->data.V[0] == NULL) {
-        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
-    }
-
-    for(int i = 1; i < numRows; i++) {
-        image->data.V[i] = (void*)((int8_t*)image->data.V[i-1]+rowSize);
-    }
-
-    *(int*)&image->col0 = 0;
-    *(int*)&image->row0 = 0;
-    *(unsigned int*)&image->numCols = numCols;
-    *(unsigned int*)&image->numRows = numRows;
-    *(psDimen*)&image->type.dimen = PS_DIMEN_IMAGE;
-    *(psElemType*)&image->type.type = type;
+    psImage *image = (psImage *) psAlloc(sizeof(psImage));
+
+    if (image == NULL) {
+        psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
+    }
+
+    p_psMemSetDeallocator(image, (psFreeFcn) imageFree);
+
+    image->data.V = psAlloc(sizeof(void *) * numRows);
+    if (image->data.V == NULL) {
+        psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
+    }
+
+    image->data.V[0] = psAlloc(area * elementSize);
+    if (image->data.V[0] == NULL) {
+        psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
+    }
+
+    for (int i = 1; i < numRows; i++) {
+        image->data.V[i] = (void *)((int8_t *) image->data.V[i - 1] + rowSize);
+    }
+
+    *(int *)&image->col0 = 0;
+    *(int *)&image->row0 = 0;
+    *(unsigned int *)&image->numCols = numCols;
+    *(unsigned int *)&image->numRows = numRows;
+    *(psDimen *) & image->type.dimen = PS_DIMEN_IMAGE;
+    *(psElemType *) & image->type.type = type;
     image->parent = NULL;
     image->nChildren = 0;
@@ -85,5 +96,5 @@
 }
 
-static void imageFree(psImage* image)
+static void imageFree(psImage * image)
 {
     if (image == NULL) {
@@ -92,12 +103,13 @@
 
     if (image->type.type == PS_TYPE_PTR) {
-        // 2-D array of pointers -- must dereference
+        // 2-D array of pointers -- must
+        // dereference
         unsigned int oldNumRows = image->numRows;
         unsigned int oldNumCols = image->numCols;
-        psPTR* rowPtr;
-
-        for(unsigned int row=0;row<oldNumRows;row++) {
+        psPTR *rowPtr;
+
+        for (unsigned int row = 0; row < oldNumRows; row++) {
             rowPtr = image->data.PTR[row];
-            for (unsigned int col=0;col<oldNumCols;col++) {
+            for (unsigned int col = 0; col < oldNumCols; col++) {
                 psMemDecrRefCounter(rowPtr[col]);
             }
@@ -112,31 +124,36 @@
 }
 
-psImage* psImageRecycle(psImage* old,
-                        unsigned int numCols,
-                        unsigned int numRows,
-                        const psElemType type)
+psImage *psImageRecycle(psImage * old, unsigned int numCols, unsigned int numRows, const psElemType type)
 {
-    int elementSize = PSELEMTYPE_SIZEOF(type); // element size in bytes
-    int rowSize = numCols*elementSize;  // row size in bytes.
+    int elementSize = PSELEMTYPE_SIZEOF(type);  // element
+
+    // size in
+    // bytes
+    int rowSize = numCols * elementSize;        // row
+
+    // size
+
+    // in bytes.
 
     if (old == NULL) {
-        old = psImageAlloc(numCols,numRows,type);
+        old = psImageAlloc(numCols, numRows, type);
         return old;
     }
 
     if (old->type.dimen != PS_DIMEN_IMAGE) {
-        psError(__func__,"Can not realloc image because input is not an image.");
+        psError(__func__, "Can not realloc image because input is not an image.");
         return NULL;
     }
 
     if (old->type.type == PS_TYPE_PTR) {
-        // 2-D array of pointers -- must dereference
+        // 2-D array of pointers -- must
+        // dereference
         unsigned int oldNumRows = old->numRows;
         unsigned int oldNumCols = old->numCols;
-        psPTR* rowPtr;
-
-        for(unsigned int row=0;row<oldNumRows;row++) {
+        psPTR *rowPtr;
+
+        for (unsigned int row = 0; row < oldNumRows; row++) {
             rowPtr = old->data.PTR[row];
-            for (unsigned int col=0;col<oldNumCols;col++) {
+            for (unsigned int col = 0; col < oldNumCols; col++) {
                 psMemDecrRefCounter(rowPtr[col]);
                 rowPtr[col] = NULL;
@@ -146,26 +163,24 @@
 
     /* image already the right size/type? */
-    if (numCols == old->numCols && numRows == old->numRows &&
-            type == old->type.type) {
+    if (numCols == old->numCols && numRows == old->numRows && type == old->type.type) {
         return old;
     }
-
     // Resize the image buffer
-    old->data.V[0] = psRealloc(old->data.V[0],numCols * numRows * elementSize);
-    old->data.V = (void**) psRealloc(old->data.V,numRows * sizeof(void*));
+    old->data.V[0] = psRealloc(old->data.V[0], numCols * numRows * elementSize);
+    old->data.V = (void **)psRealloc(old->data.V, numRows * sizeof(void *));
 
     // recreate the row pointers
-    for(int i = 1; i < numRows; i++) {
-        old->data.V[i] = (void*)((int8_t*)old->data.V[i-1]+rowSize);
-    }
-
-    *(unsigned int*)&old->numCols = numCols;
-    *(unsigned int*)&old->numRows = numRows;
-    *(psElemType*)&old->type.type = type;
+    for (int i = 1; i < numRows; i++) {
+        old->data.V[i] = (void *)((int8_t *) old->data.V[i - 1] + rowSize);
+    }
+
+    *(unsigned int *)&old->numCols = numCols;
+    *(unsigned int *)&old->numRows = numRows;
+    *(psElemType *) & old->type.type = type;
 
     return old;
 }
 
-int psImageFreeChildren(psImage* image)
+int psImageFreeChildren(psImage * image)
 {
     int i = 0;
@@ -181,5 +196,5 @@
     children = image->children;
 
-    for(i=0; i<nChildren; i++) {
+    for (i = 0; i < nChildren; i++) {
         if (children[i] != NULL) {
             numFreed++;
@@ -191,5 +206,4 @@
     image->nChildren = 0;
     image->children = NULL;
-
 
     return numFreed;
@@ -202,17 +216,12 @@
 linear interpolation is performed on the image.
  *****************************************************************************/
-psF32 psImagePixelInterpolate(
-    const psImage *input,
-    float x,
-    float y,
-    psF32 unexposedValue,
-    psImageInterpolateMode mode)
+psF32 psImagePixelInterpolate(const psImage * input,
+                              float x, float y, psF32 unexposedValue, psImageInterpolateMode mode)
 {
 
     if (input == NULL) {
-        psError(__func__,"Image can not be NULL.");
+        psError(__func__, "Image can not be NULL.");
         return unexposedValue;
     }
-
     #define PSIMAGE_PIXEL_INTERPOLATE_CASE(TYPE) \
 case PS_TYPE_##TYPE: \
@@ -243,5 +252,5 @@
         PSIMAGE_PIXEL_INTERPOLATE_CASE(C64);
     default:
-        psError(__func__,"Unsupported image datatype (%d)",input->type.type);
+        psError(__func__, "Unsupported image datatype (%d)", input->type.type);
     }
 
@@ -303,5 +312,4 @@
 PSIMAGE_PIXEL_INTERPOLATE_FLAT_COMPLEX(C32)
 PSIMAGE_PIXEL_INTERPOLATE_FLAT_COMPLEX(C64)
-
 #define PSIMAGE_PIXEL_INTERPOLATE_BILINEAR(TYPE) \
 inline psF64 p_psImagePixelInterpolateBILINEAR_##TYPE(const psImage *input, \
@@ -359,5 +367,4 @@
     return(pixel); \
 }
-
 #define PSIMAGE_PIXEL_INTERPOLATE_BILINEAR_COMPLEX(TYPE) \
 inline psC64 p_psImagePixelInterpolateBILINEAR_##TYPE(const psImage *input, \
@@ -428,4 +435,2 @@
 PSIMAGE_PIXEL_INTERPOLATE_BILINEAR_COMPLEX(C32)
 PSIMAGE_PIXEL_INTERPOLATE_BILINEAR_COMPLEX(C64)
-
-
