Index: /trunk/psLib/src/image/psImage.c
===================================================================
--- /trunk/psLib/src/image/psImage.c	(revision 858)
+++ /trunk/psLib/src/image/psImage.c	(revision 859)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-01 22:42:57 $
+ *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-04 03:15:47 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -238,4 +238,9 @@
         }
     }
+    psFree(children);
+
+    image->nChildren = 0;
+    image->children = NULL;
+
 
     return numFreed;
@@ -292,5 +297,5 @@
             out = OUT->data.OUTTYPE[row]; \
             for (int col=0;col<numCols;col++) { \
-                in[col] = (ps##INTYPE) out[col]; \
+                out[col] = (ps##OUTTYPE) in[col]; \
             } \
         } \
@@ -340,5 +345,11 @@
     }
 
-    switch (type) {
+    // XXX - GCC had problems with the length? of the above macro.  The original
+    // macro code here is commented out and the preprocessor output is pasted below it
+    // (effectively to the end of the function)
+    // We need to find out what is doing on here and move back to the macro version.
+    #if 0
+    switch (type)
+    {
     case PS_TYPE_S8:
         PSIMAGE_ELEMENT_ASSIGN(output,input,S8);
@@ -355,5 +366,4 @@
     case PS_TYPE_U8:
         PSIMAGE_ELEMENT_ASSIGN(output,input,U8);
-        break;
     case PS_TYPE_U16:
         PSIMAGE_ELEMENT_ASSIGN(output,input,U16);
@@ -381,4 +391,1717 @@
         psImageFree(output);
         return NULL;
+    }
+    #endif
+
+    #if 1
+    switch (type) {
+    case PS_TYPE_S8:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_S16:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_S32:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_S64:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_U8:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_U16:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_U32:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_U64:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_F32:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_F64:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_C32:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_C64:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_PTR:
+        psError (__func__, "Can't copy image into a matrix of pointers.");
+        psImageFree (output);
+        return ((void *) 0);
     }
 
@@ -575,4 +2298,6 @@
     }
 
+    #endif
+
     return 0;
 }
Index: /trunk/psLib/src/mathtypes/psImage.c
===================================================================
--- /trunk/psLib/src/mathtypes/psImage.c	(revision 858)
+++ /trunk/psLib/src/mathtypes/psImage.c	(revision 859)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-01 22:42:57 $
+ *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-04 03:15:47 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -238,4 +238,9 @@
         }
     }
+    psFree(children);
+
+    image->nChildren = 0;
+    image->children = NULL;
+
 
     return numFreed;
@@ -292,5 +297,5 @@
             out = OUT->data.OUTTYPE[row]; \
             for (int col=0;col<numCols;col++) { \
-                in[col] = (ps##INTYPE) out[col]; \
+                out[col] = (ps##OUTTYPE) in[col]; \
             } \
         } \
@@ -340,5 +345,11 @@
     }
 
-    switch (type) {
+    // XXX - GCC had problems with the length? of the above macro.  The original
+    // macro code here is commented out and the preprocessor output is pasted below it
+    // (effectively to the end of the function)
+    // We need to find out what is doing on here and move back to the macro version.
+    #if 0
+    switch (type)
+    {
     case PS_TYPE_S8:
         PSIMAGE_ELEMENT_ASSIGN(output,input,S8);
@@ -355,5 +366,4 @@
     case PS_TYPE_U8:
         PSIMAGE_ELEMENT_ASSIGN(output,input,U8);
-        break;
     case PS_TYPE_U16:
         PSIMAGE_ELEMENT_ASSIGN(output,input,U16);
@@ -381,4 +391,1717 @@
         psImageFree(output);
         return NULL;
+    }
+    #endif
+
+    #if 1
+    switch (type) {
+    case PS_TYPE_S8:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psS8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.S8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_S16:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psS16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.S16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_S32:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psS32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.S32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_S64:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psS64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.S64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psS64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_U8:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psU8 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.U8[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU8) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_U16:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psU16 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.U16[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU16) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_U32:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psU32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.U32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_U64:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psU64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.U64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psU64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_F32:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psF32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.F32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_F64:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psF64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.F64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psF64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_C32:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psC32 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.C32[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC32) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_C64:
+        switch (input->type.type) {
+        case PS_TYPE_S8: {
+                psS8 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S8[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S16: {
+                psS16 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S16[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S32: {
+                psS32 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S32[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_S64: {
+                psS64 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.S64[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U8: {
+                psU8 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U8[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U16: {
+                psU16 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U16[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U32: {
+                psU32 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U32[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_U64: {
+                psU64 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.U64[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F32: {
+                psF32 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F32[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_F64: {
+                psF64 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.F64[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_C32: {
+                psC32 *in;
+                psC64 *out;
+                for (int row = 0; row < numRows; row++) {
+                    in = input->data.C32[row];
+                    out = output->data.C64[row];
+                    for (int col = 0; col < numCols; col++) {
+                        out[col] = (psC64) in[col];
+                    }
+                }
+            };
+            break;
+        case PS_TYPE_PTR:
+            psError (__func__, "Can't copy image from a matrix of pointers.");
+            psImageFree (output);
+            return ((void *) 0);
+        default:
+            break;
+        };
+        break;
+    case PS_TYPE_PTR:
+        psError (__func__, "Can't copy image into a matrix of pointers.");
+        psImageFree (output);
+        return ((void *) 0);
     }
 
@@ -575,4 +2298,6 @@
     }
 
+    #endif
+
     return 0;
 }
