Index: trunk/psLib/src/image/psImageFFT.c
===================================================================
--- trunk/psLib/src/image/psImageFFT.c	(revision 3671)
+++ trunk/psLib/src/image/psImageFFT.c	(revision 3702)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-04-06 01:12:58 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-04-15 00:12:08 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -74,8 +74,11 @@
     // n.b. FFTW can perform a in-place transform at the same rate or faster than out-of-place.
     psS32 sign = ((direction & PS_FFT_FORWARD) != 0) ? FFTW_FORWARD : FFTW_BACKWARD;
-    out = psImageCopy(out, in, PS_TYPE_C32);
-    plan = fftwf_plan_dft_2d(numCols, numRows,
-                             out->data.C32[0],
-                             out->data.C32[0],
+
+    fftwf_complex* outBuffer = fftwf_malloc(numRows*numCols*sizeof(fftwf_complex));
+    p_psImageCopyToRawBuffer(outBuffer, in, PS_TYPE_C32);
+
+    plan = fftwf_plan_dft_2d(numRows, numCols,
+                             outBuffer,
+                             outBuffer,
                              sign,
                              PS_FFTW_PLAN_RIGOR);
@@ -101,8 +104,25 @@
         // becomes an issue, the use of fftwf_plan_dft_r2c should be considered
         // as well as fftwf_plan_dft_c2r.
-        psImage* realOut = psImageCopy(NULL,out,PS_TYPE_F32);
-        psFree(out);
-        out = realOut;
-    }
+        out = psImageRecycle(out,numCols,numRows,PS_TYPE_F32);
+        int index = 0;
+        for (int row=0; row < numRows; row++) {
+            psF32* outRow = out->data.F32[row];
+            for (int col=0; col < numCols; col++) {
+                outRow[col] = crealf(outBuffer[index++]); // take just the real part
+            }
+        }
+    } else {
+        out = psImageRecycle(out,numCols,numRows,PS_TYPE_C32);
+        int index = 0;
+        for (int row=0; row < numRows; row++) {
+            psC32* outRow = out->data.C32[row];
+            for (int col=0; col < numCols; col++) {
+                outRow[col] = outBuffer[index++]; // take just the real part
+            }
+        }
+        //        memcpy(out->rawDataBuffer, outBuffer, numRows*numCols*sizeof(fftwf_complex));
+    }
+
+    fftwf_free(outBuffer);
 
     return out;
