IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 7, 2004, 3:05:01 PM (22 years ago)
Author:
desonia
Message:

rewrote psImageCopy so that macro need not be expanded.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/image/psImage.c

    r1165 r1193  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-07-01 00:26:37 $
     11 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-07-08 01:05:00 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    261261}
    262262
     263
     264
    263265psImage *psImageCopy(psImage* restrict output, const psImage *input,
    264266                     psElemType type)
     
    266268    psElemType inDatatype;
    267269    int elementSize;
     270    int elements;
    268271    int numRows;
    269272    int numCols;
     
    288291    numRows = input->numRows;
    289292    numCols = input->numCols;
     293    elements = numRows*numCols;
    290294    elementSize = PSELEMTYPE_SIZEOF(inDatatype);
    291295
     
    299303    // cover the trival case of copy of the same datatype.
    300304    if (type == inDatatype) {
    301         memcpy(output->data.V[0],input->data.V[0],elementSize*numRows*numCols);
     305        memcpy(output->data.V[0],input->data.V[0],elementSize*elements);
    302306        return output;
    303307    }
    304308
    305     #define PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,INTYPE,OUTTYPE) \
    306     { \
    307         ps##INTYPE *in; \
    308         ps##OUTTYPE *out; \
    309         for (int row=0;row<numRows;row++) { \
    310             in = IN->data.INTYPE[row]; \
    311             out = OUT->data.OUTTYPE[row]; \
    312             for (int col=0;col<numCols;col++) { \
    313                 out[col] = (ps##OUTTYPE) in[col]; \
    314             } \
     309    #define PSIMAGE_ELEMENT_COPY(IN,INTYPE,OUT,OUTTYPE,ELEMENTS) { \
     310        ps##INTYPE *in = IN->data.INTYPE[0]; \
     311        ps##OUTTYPE *out = OUT->data.OUTTYPE[0]; \
     312        for (int e=0;e<ELEMENTS;e++) { \
     313            *(out++) = *(in++); \
    315314        } \
    316315    }
    317316
    318     #define PSIMAGE_ELEMENT_ASSIGN(OUT,IN,OUTTYPE) \
    319     switch (IN->type.type) { \
     317    #define PSIMAGE_COPY_CASE(OUT,OUTTYPE) \
     318    switch (inDatatype) { \
    320319    case PS_TYPE_S8: \
    321         PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,S8,OUTTYPE); \
     320        PSIMAGE_ELEMENT_COPY(input,S8,OUT,OUTTYPE,elements); \
    322321        break; \
    323322    case PS_TYPE_S16: \
    324         PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,S16,OUTTYPE); \
     323        PSIMAGE_ELEMENT_COPY(input,S16,OUT,OUTTYPE,elements); \
    325324        break; \
    326325    case PS_TYPE_S32: \
    327         PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,S32,OUTTYPE); \
     326        PSIMAGE_ELEMENT_COPY(input,S32,OUT,OUTTYPE,elements); \
    328327        break; \
    329328    case PS_TYPE_S64: \
    330         PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,S64,OUTTYPE); \
     329        PSIMAGE_ELEMENT_COPY(input,S64,OUT,OUTTYPE,elements); \
    331330        break; \
    332331    case PS_TYPE_U8: \
    333         PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,U8,OUTTYPE); \
     332        PSIMAGE_ELEMENT_COPY(input,U8,OUT,OUTTYPE,elements); \
    334333        break; \
    335334    case PS_TYPE_U16: \
    336         PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,U16,OUTTYPE); \
     335        PSIMAGE_ELEMENT_COPY(input,U16,OUT,OUTTYPE,elements); \
    337336        break; \
    338337    case PS_TYPE_U32: \
    339         PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,U32,OUTTYPE); \
     338        PSIMAGE_ELEMENT_COPY(input,U32,OUT,OUTTYPE,elements); \
    340339        break; \
    341340    case PS_TYPE_U64: \
    342         PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,U64,OUTTYPE); \
     341        PSIMAGE_ELEMENT_COPY(input,U64,OUT,OUTTYPE,elements); \
    343342        break; \
    344343    case PS_TYPE_F32: \
    345         PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,F32,OUTTYPE); \
     344        PSIMAGE_ELEMENT_COPY(input,F32,OUT,OUTTYPE,elements); \
    346345        break; \
    347346    case PS_TYPE_F64: \
    348         PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,F64,OUTTYPE); \
     347        PSIMAGE_ELEMENT_COPY(input,F64,OUT,OUTTYPE,elements); \
    349348        break; \
    350349    case PS_TYPE_C32: \
    351         PSIMAGE_ELEMENT_ASSIGN_LOOP(OUT,IN,C32,OUTTYPE); \
    352         break; \
    353     case PS_TYPE_PTR: \
    354         psError(__func__,"Can't copy image from a matrix of pointers."); \
    355         psFree(output); \
    356         return NULL; \
     350        PSIMAGE_ELEMENT_COPY(input,C32,OUT,OUTTYPE,elements); \
     351        break; \
     352    case PS_TYPE_C64: \
     353        PSIMAGE_ELEMENT_COPY(input,C64,OUT,OUTTYPE,elements); \
     354        break; \
    357355    default: \
    358356        break; \
    359357    }
    360358
    361     // XXX - GCC had problems with the length? of the above macro.  The original
    362     // macro code here is commented out and the preprocessor output is pasted below it
    363     // (effectively to the end of the function)
    364     // We need to find out what is doing on here and move back to the macro version.
    365     #if 0
    366     switch (type)
    367     {
    368     case PS_TYPE_S8:
    369         PSIMAGE_ELEMENT_ASSIGN(output,input,S8);
    370         break;
    371     case PS_TYPE_S16:
    372         PSIMAGE_ELEMENT_ASSIGN(output,input,S16);
    373         break;
    374     case PS_TYPE_S32:
    375         PSIMAGE_ELEMENT_ASSIGN(output,input,S32);
    376         break;
    377     case PS_TYPE_S64:
    378         PSIMAGE_ELEMENT_ASSIGN(output,input,S64);
    379         break;
    380     case PS_TYPE_U8:
    381         PSIMAGE_ELEMENT_ASSIGN(output,input,U8);
    382     case PS_TYPE_U16:
    383         PSIMAGE_ELEMENT_ASSIGN(output,input,U16);
    384         break;
    385     case PS_TYPE_U32:
    386         PSIMAGE_ELEMENT_ASSIGN(output,input,U32);
    387         break;
    388     case PS_TYPE_U64:
    389         PSIMAGE_ELEMENT_ASSIGN(output,input,U64);
    390         break;
    391     case PS_TYPE_F32:
    392         PSIMAGE_ELEMENT_ASSIGN(output,input,F32);
    393         break;
    394     case PS_TYPE_F64:
    395         PSIMAGE_ELEMENT_ASSIGN(output,input,F64);
    396         break;
    397     case PS_TYPE_C32:
    398         PSIMAGE_ELEMENT_ASSIGN(output,input,C32);
    399         break;
    400     case PS_TYPE_C64:
    401         PSIMAGE_ELEMENT_ASSIGN(output,input,C64);
    402         break;
    403     case PS_TYPE_PTR:
    404         psError(__func__,"Can't copy image into a matrix of pointers.");
    405         psFree(output);
    406         return NULL;
    407     }
    408     #endif
    409 
    410     #if 1
    411359    switch (type) {
    412360    case PS_TYPE_S8:
    413         switch (input->type.type) {
    414         case PS_TYPE_S8: {
    415                 psS8 *in;
    416                 psS8 *out;
    417                 for (int row = 0; row < numRows; row++) {
    418                     in = input->data.S8[row];
    419                     out = output->data.S8[row];
    420                     for (int col = 0; col < numCols; col++) {
    421                         out[col] = (psS8) in[col];
    422                     }
    423                 }
    424             };
    425             break;
    426         case PS_TYPE_S16: {
    427                 psS16 *in;
    428                 psS8 *out;
    429                 for (int row = 0; row < numRows; row++) {
    430                     in = input->data.S16[row];
    431                     out = output->data.S8[row];
    432                     for (int col = 0; col < numCols; col++) {
    433                         out[col] = (psS8) in[col];
    434                     }
    435                 }
    436             };
    437             break;
    438         case PS_TYPE_S32: {
    439                 psS32 *in;
    440                 psS8 *out;
    441                 for (int row = 0; row < numRows; row++) {
    442                     in = input->data.S32[row];
    443                     out = output->data.S8[row];
    444                     for (int col = 0; col < numCols; col++) {
    445                         out[col] = (psS8) in[col];
    446                     }
    447                 }
    448             };
    449             break;
    450         case PS_TYPE_S64: {
    451                 psS64 *in;
    452                 psS8 *out;
    453                 for (int row = 0; row < numRows; row++) {
    454                     in = input->data.S64[row];
    455                     out = output->data.S8[row];
    456                     for (int col = 0; col < numCols; col++) {
    457                         out[col] = (psS8) in[col];
    458                     }
    459                 }
    460             };
    461             break;
    462         case PS_TYPE_U8: {
    463                 psU8 *in;
    464                 psS8 *out;
    465                 for (int row = 0; row < numRows; row++) {
    466                     in = input->data.U8[row];
    467                     out = output->data.S8[row];
    468                     for (int col = 0; col < numCols; col++) {
    469                         out[col] = (psS8) in[col];
    470                     }
    471                 }
    472             };
    473             break;
    474         case PS_TYPE_U16: {
    475                 psU16 *in;
    476                 psS8 *out;
    477                 for (int row = 0; row < numRows; row++) {
    478                     in = input->data.U16[row];
    479                     out = output->data.S8[row];
    480                     for (int col = 0; col < numCols; col++) {
    481                         out[col] = (psS8) in[col];
    482                     }
    483                 }
    484             };
    485             break;
    486         case PS_TYPE_U32: {
    487                 psU32 *in;
    488                 psS8 *out;
    489                 for (int row = 0; row < numRows; row++) {
    490                     in = input->data.U32[row];
    491                     out = output->data.S8[row];
    492                     for (int col = 0; col < numCols; col++) {
    493                         out[col] = (psS8) in[col];
    494                     }
    495                 }
    496             };
    497             break;
    498         case PS_TYPE_U64: {
    499                 psU64 *in;
    500                 psS8 *out;
    501                 for (int row = 0; row < numRows; row++) {
    502                     in = input->data.U64[row];
    503                     out = output->data.S8[row];
    504                     for (int col = 0; col < numCols; col++) {
    505                         out[col] = (psS8) in[col];
    506                     }
    507                 }
    508             };
    509             break;
    510         case PS_TYPE_F32: {
    511                 psF32 *in;
    512                 psS8 *out;
    513                 for (int row = 0; row < numRows; row++) {
    514                     in = input->data.F32[row];
    515                     out = output->data.S8[row];
    516                     for (int col = 0; col < numCols; col++) {
    517                         out[col] = (psS8) in[col];
    518                     }
    519                 }
    520             };
    521             break;
    522         case PS_TYPE_F64: {
    523                 psF64 *in;
    524                 psS8 *out;
    525                 for (int row = 0; row < numRows; row++) {
    526                     in = input->data.F64[row];
    527                     out = output->data.S8[row];
    528                     for (int col = 0; col < numCols; col++) {
    529                         out[col] = (psS8) in[col];
    530                     }
    531                 }
    532             };
    533             break;
    534         case PS_TYPE_C32: {
    535                 psC32 *in;
    536                 psS8 *out;
    537                 for (int row = 0; row < numRows; row++) {
    538                     in = input->data.C32[row];
    539                     out = output->data.S8[row];
    540                     for (int col = 0; col < numCols; col++) {
    541                         out[col] = (psS8) in[col];
    542                     }
    543                 }
    544             };
    545             break;
    546         case PS_TYPE_PTR:
    547             psError (__func__, "Can't copy image from a matrix of pointers.");
    548             psFree (output);
    549             return ((void *) 0);
    550         default:
    551             break;
    552         };
     361        PSIMAGE_COPY_CASE(output,S8);
    553362        break;
    554363    case PS_TYPE_S16:
    555         switch (input->type.type) {
    556         case PS_TYPE_S8: {
    557                 psS8 *in;
    558                 psS16 *out;
    559                 for (int row = 0; row < numRows; row++) {
    560                     in = input->data.S8[row];
    561                     out = output->data.S16[row];
    562                     for (int col = 0; col < numCols; col++) {
    563                         out[col] = (psS16) in[col];
    564                     }
    565                 }
    566             };
    567             break;
    568         case PS_TYPE_S16: {
    569                 psS16 *in;
    570                 psS16 *out;
    571                 for (int row = 0; row < numRows; row++) {
    572                     in = input->data.S16[row];
    573                     out = output->data.S16[row];
    574                     for (int col = 0; col < numCols; col++) {
    575                         out[col] = (psS16) in[col];
    576                     }
    577                 }
    578             };
    579             break;
    580         case PS_TYPE_S32: {
    581                 psS32 *in;
    582                 psS16 *out;
    583                 for (int row = 0; row < numRows; row++) {
    584                     in = input->data.S32[row];
    585                     out = output->data.S16[row];
    586                     for (int col = 0; col < numCols; col++) {
    587                         out[col] = (psS16) in[col];
    588                     }
    589                 }
    590             };
    591             break;
    592         case PS_TYPE_S64: {
    593                 psS64 *in;
    594                 psS16 *out;
    595                 for (int row = 0; row < numRows; row++) {
    596                     in = input->data.S64[row];
    597                     out = output->data.S16[row];
    598                     for (int col = 0; col < numCols; col++) {
    599                         out[col] = (psS16) in[col];
    600                     }
    601                 }
    602             };
    603             break;
    604         case PS_TYPE_U8: {
    605                 psU8 *in;
    606                 psS16 *out;
    607                 for (int row = 0; row < numRows; row++) {
    608                     in = input->data.U8[row];
    609                     out = output->data.S16[row];
    610                     for (int col = 0; col < numCols; col++) {
    611                         out[col] = (psS16) in[col];
    612                     }
    613                 }
    614             };
    615             break;
    616         case PS_TYPE_U16: {
    617                 psU16 *in;
    618                 psS16 *out;
    619                 for (int row = 0; row < numRows; row++) {
    620                     in = input->data.U16[row];
    621                     out = output->data.S16[row];
    622                     for (int col = 0; col < numCols; col++) {
    623                         out[col] = (psS16) in[col];
    624                     }
    625                 }
    626             };
    627             break;
    628         case PS_TYPE_U32: {
    629                 psU32 *in;
    630                 psS16 *out;
    631                 for (int row = 0; row < numRows; row++) {
    632                     in = input->data.U32[row];
    633                     out = output->data.S16[row];
    634                     for (int col = 0; col < numCols; col++) {
    635                         out[col] = (psS16) in[col];
    636                     }
    637                 }
    638             };
    639             break;
    640         case PS_TYPE_U64: {
    641                 psU64 *in;
    642                 psS16 *out;
    643                 for (int row = 0; row < numRows; row++) {
    644                     in = input->data.U64[row];
    645                     out = output->data.S16[row];
    646                     for (int col = 0; col < numCols; col++) {
    647                         out[col] = (psS16) in[col];
    648                     }
    649                 }
    650             };
    651             break;
    652         case PS_TYPE_F32: {
    653                 psF32 *in;
    654                 psS16 *out;
    655                 for (int row = 0; row < numRows; row++) {
    656                     in = input->data.F32[row];
    657                     out = output->data.S16[row];
    658                     for (int col = 0; col < numCols; col++) {
    659                         out[col] = (psS16) in[col];
    660                     }
    661                 }
    662             };
    663             break;
    664         case PS_TYPE_F64: {
    665                 psF64 *in;
    666                 psS16 *out;
    667                 for (int row = 0; row < numRows; row++) {
    668                     in = input->data.F64[row];
    669                     out = output->data.S16[row];
    670                     for (int col = 0; col < numCols; col++) {
    671                         out[col] = (psS16) in[col];
    672                     }
    673                 }
    674             };
    675             break;
    676         case PS_TYPE_C32: {
    677                 psC32 *in;
    678                 psS16 *out;
    679                 for (int row = 0; row < numRows; row++) {
    680                     in = input->data.C32[row];
    681                     out = output->data.S16[row];
    682                     for (int col = 0; col < numCols; col++) {
    683                         out[col] = (psS16) in[col];
    684                     }
    685                 }
    686             };
    687             break;
    688         case PS_TYPE_PTR:
    689             psError (__func__, "Can't copy image from a matrix of pointers.");
    690             psFree (output);
    691             return ((void *) 0);
    692         default:
    693             break;
    694         };
     364        PSIMAGE_COPY_CASE(output,S16);
    695365        break;
    696366    case PS_TYPE_S32:
    697         switch (input->type.type) {
    698         case PS_TYPE_S8: {
    699                 psS8 *in;
    700                 psS32 *out;
    701                 for (int row = 0; row < numRows; row++) {
    702                     in = input->data.S8[row];
    703                     out = output->data.S32[row];
    704                     for (int col = 0; col < numCols; col++) {
    705                         out[col] = (psS32) in[col];
    706                     }
    707                 }
    708             };
    709             break;
    710         case PS_TYPE_S16: {
    711                 psS16 *in;
    712                 psS32 *out;
    713                 for (int row = 0; row < numRows; row++) {
    714                     in = input->data.S16[row];
    715                     out = output->data.S32[row];
    716                     for (int col = 0; col < numCols; col++) {
    717                         out[col] = (psS32) in[col];
    718                     }
    719                 }
    720             };
    721             break;
    722         case PS_TYPE_S32: {
    723                 psS32 *in;
    724                 psS32 *out;
    725                 for (int row = 0; row < numRows; row++) {
    726                     in = input->data.S32[row];
    727                     out = output->data.S32[row];
    728                     for (int col = 0; col < numCols; col++) {
    729                         out[col] = (psS32) in[col];
    730                     }
    731                 }
    732             };
    733             break;
    734         case PS_TYPE_S64: {
    735                 psS64 *in;
    736                 psS32 *out;
    737                 for (int row = 0; row < numRows; row++) {
    738                     in = input->data.S64[row];
    739                     out = output->data.S32[row];
    740                     for (int col = 0; col < numCols; col++) {
    741                         out[col] = (psS32) in[col];
    742                     }
    743                 }
    744             };
    745             break;
    746         case PS_TYPE_U8: {
    747                 psU8 *in;
    748                 psS32 *out;
    749                 for (int row = 0; row < numRows; row++) {
    750                     in = input->data.U8[row];
    751                     out = output->data.S32[row];
    752                     for (int col = 0; col < numCols; col++) {
    753                         out[col] = (psS32) in[col];
    754                     }
    755                 }
    756             };
    757             break;
    758         case PS_TYPE_U16: {
    759                 psU16 *in;
    760                 psS32 *out;
    761                 for (int row = 0; row < numRows; row++) {
    762                     in = input->data.U16[row];
    763                     out = output->data.S32[row];
    764                     for (int col = 0; col < numCols; col++) {
    765                         out[col] = (psS32) in[col];
    766                     }
    767                 }
    768             };
    769             break;
    770         case PS_TYPE_U32: {
    771                 psU32 *in;
    772                 psS32 *out;
    773                 for (int row = 0; row < numRows; row++) {
    774                     in = input->data.U32[row];
    775                     out = output->data.S32[row];
    776                     for (int col = 0; col < numCols; col++) {
    777                         out[col] = (psS32) in[col];
    778                     }
    779                 }
    780             };
    781             break;
    782         case PS_TYPE_U64: {
    783                 psU64 *in;
    784                 psS32 *out;
    785                 for (int row = 0; row < numRows; row++) {
    786                     in = input->data.U64[row];
    787                     out = output->data.S32[row];
    788                     for (int col = 0; col < numCols; col++) {
    789                         out[col] = (psS32) in[col];
    790                     }
    791                 }
    792             };
    793             break;
    794         case PS_TYPE_F32: {
    795                 psF32 *in;
    796                 psS32 *out;
    797                 for (int row = 0; row < numRows; row++) {
    798                     in = input->data.F32[row];
    799                     out = output->data.S32[row];
    800                     for (int col = 0; col < numCols; col++) {
    801                         out[col] = (psS32) in[col];
    802                     }
    803                 }
    804             };
    805             break;
    806         case PS_TYPE_F64: {
    807                 psF64 *in;
    808                 psS32 *out;
    809                 for (int row = 0; row < numRows; row++) {
    810                     in = input->data.F64[row];
    811                     out = output->data.S32[row];
    812                     for (int col = 0; col < numCols; col++) {
    813                         out[col] = (psS32) in[col];
    814                     }
    815                 }
    816             };
    817             break;
    818         case PS_TYPE_C32: {
    819                 psC32 *in;
    820                 psS32 *out;
    821                 for (int row = 0; row < numRows; row++) {
    822                     in = input->data.C32[row];
    823                     out = output->data.S32[row];
    824                     for (int col = 0; col < numCols; col++) {
    825                         out[col] = (psS32) in[col];
    826                     }
    827                 }
    828             };
    829             break;
    830         case PS_TYPE_PTR:
    831             psError (__func__, "Can't copy image from a matrix of pointers.");
    832             psFree (output);
    833             return ((void *) 0);
    834         default:
    835             break;
    836         };
     367        PSIMAGE_COPY_CASE(output,S32);
    837368        break;
    838369    case PS_TYPE_S64:
    839         switch (input->type.type) {
    840         case PS_TYPE_S8: {
    841                 psS8 *in;
    842                 psS64 *out;
    843                 for (int row = 0; row < numRows; row++) {
    844                     in = input->data.S8[row];
    845                     out = output->data.S64[row];
    846                     for (int col = 0; col < numCols; col++) {
    847                         out[col] = (psS64) in[col];
    848                     }
    849                 }
    850             };
    851             break;
    852         case PS_TYPE_S16: {
    853                 psS16 *in;
    854                 psS64 *out;
    855                 for (int row = 0; row < numRows; row++) {
    856                     in = input->data.S16[row];
    857                     out = output->data.S64[row];
    858                     for (int col = 0; col < numCols; col++) {
    859                         out[col] = (psS64) in[col];
    860                     }
    861                 }
    862             };
    863             break;
    864         case PS_TYPE_S32: {
    865                 psS32 *in;
    866                 psS64 *out;
    867                 for (int row = 0; row < numRows; row++) {
    868                     in = input->data.S32[row];
    869                     out = output->data.S64[row];
    870                     for (int col = 0; col < numCols; col++) {
    871                         out[col] = (psS64) in[col];
    872                     }
    873                 }
    874             };
    875             break;
    876         case PS_TYPE_S64: {
    877                 psS64 *in;
    878                 psS64 *out;
    879                 for (int row = 0; row < numRows; row++) {
    880                     in = input->data.S64[row];
    881                     out = output->data.S64[row];
    882                     for (int col = 0; col < numCols; col++) {
    883                         out[col] = (psS64) in[col];
    884                     }
    885                 }
    886             };
    887             break;
    888         case PS_TYPE_U8: {
    889                 psU8 *in;
    890                 psS64 *out;
    891                 for (int row = 0; row < numRows; row++) {
    892                     in = input->data.U8[row];
    893                     out = output->data.S64[row];
    894                     for (int col = 0; col < numCols; col++) {
    895                         out[col] = (psS64) in[col];
    896                     }
    897                 }
    898             };
    899             break;
    900         case PS_TYPE_U16: {
    901                 psU16 *in;
    902                 psS64 *out;
    903                 for (int row = 0; row < numRows; row++) {
    904                     in = input->data.U16[row];
    905                     out = output->data.S64[row];
    906                     for (int col = 0; col < numCols; col++) {
    907                         out[col] = (psS64) in[col];
    908                     }
    909                 }
    910             };
    911             break;
    912         case PS_TYPE_U32: {
    913                 psU32 *in;
    914                 psS64 *out;
    915                 for (int row = 0; row < numRows; row++) {
    916                     in = input->data.U32[row];
    917                     out = output->data.S64[row];
    918                     for (int col = 0; col < numCols; col++) {
    919                         out[col] = (psS64) in[col];
    920                     }
    921                 }
    922             };
    923             break;
    924         case PS_TYPE_U64: {
    925                 psU64 *in;
    926                 psS64 *out;
    927                 for (int row = 0; row < numRows; row++) {
    928                     in = input->data.U64[row];
    929                     out = output->data.S64[row];
    930                     for (int col = 0; col < numCols; col++) {
    931                         out[col] = (psS64) in[col];
    932                     }
    933                 }
    934             };
    935             break;
    936         case PS_TYPE_F32: {
    937                 psF32 *in;
    938                 psS64 *out;
    939                 for (int row = 0; row < numRows; row++) {
    940                     in = input->data.F32[row];
    941                     out = output->data.S64[row];
    942                     for (int col = 0; col < numCols; col++) {
    943                         out[col] = (psS64) in[col];
    944                     }
    945                 }
    946             };
    947             break;
    948         case PS_TYPE_F64: {
    949                 psF64 *in;
    950                 psS64 *out;
    951                 for (int row = 0; row < numRows; row++) {
    952                     in = input->data.F64[row];
    953                     out = output->data.S64[row];
    954                     for (int col = 0; col < numCols; col++) {
    955                         out[col] = (psS64) in[col];
    956                     }
    957                 }
    958             };
    959             break;
    960         case PS_TYPE_C32: {
    961                 psC32 *in;
    962                 psS64 *out;
    963                 for (int row = 0; row < numRows; row++) {
    964                     in = input->data.C32[row];
    965                     out = output->data.S64[row];
    966                     for (int col = 0; col < numCols; col++) {
    967                         out[col] = (psS64) in[col];
    968                     }
    969                 }
    970             };
    971             break;
    972         case PS_TYPE_PTR:
    973             psError (__func__, "Can't copy image from a matrix of pointers.");
    974             psFree (output);
    975             return ((void *) 0);
    976         default:
    977             break;
    978         };
     370        PSIMAGE_COPY_CASE(output,S64);
    979371        break;
    980372    case PS_TYPE_U8:
    981         switch (input->type.type) {
    982         case PS_TYPE_S8: {
    983                 psS8 *in;
    984                 psU8 *out;
    985                 for (int row = 0; row < numRows; row++) {
    986                     in = input->data.S8[row];
    987                     out = output->data.U8[row];
    988                     for (int col = 0; col < numCols; col++) {
    989                         out[col] = (psU8) in[col];
    990                     }
    991                 }
    992             };
    993             break;
    994         case PS_TYPE_S16: {
    995                 psS16 *in;
    996                 psU8 *out;
    997                 for (int row = 0; row < numRows; row++) {
    998                     in = input->data.S16[row];
    999                     out = output->data.U8[row];
    1000                     for (int col = 0; col < numCols; col++) {
    1001                         out[col] = (psU8) in[col];
    1002                     }
    1003                 }
    1004             };
    1005             break;
    1006         case PS_TYPE_S32: {
    1007                 psS32 *in;
    1008                 psU8 *out;
    1009                 for (int row = 0; row < numRows; row++) {
    1010                     in = input->data.S32[row];
    1011                     out = output->data.U8[row];
    1012                     for (int col = 0; col < numCols; col++) {
    1013                         out[col] = (psU8) in[col];
    1014                     }
    1015                 }
    1016             };
    1017             break;
    1018         case PS_TYPE_S64: {
    1019                 psS64 *in;
    1020                 psU8 *out;
    1021                 for (int row = 0; row < numRows; row++) {
    1022                     in = input->data.S64[row];
    1023                     out = output->data.U8[row];
    1024                     for (int col = 0; col < numCols; col++) {
    1025                         out[col] = (psU8) in[col];
    1026                     }
    1027                 }
    1028             };
    1029             break;
    1030         case PS_TYPE_U8: {
    1031                 psU8 *in;
    1032                 psU8 *out;
    1033                 for (int row = 0; row < numRows; row++) {
    1034                     in = input->data.U8[row];
    1035                     out = output->data.U8[row];
    1036                     for (int col = 0; col < numCols; col++) {
    1037                         out[col] = (psU8) in[col];
    1038                     }
    1039                 }
    1040             };
    1041             break;
    1042         case PS_TYPE_U16: {
    1043                 psU16 *in;
    1044                 psU8 *out;
    1045                 for (int row = 0; row < numRows; row++) {
    1046                     in = input->data.U16[row];
    1047                     out = output->data.U8[row];
    1048                     for (int col = 0; col < numCols; col++) {
    1049                         out[col] = (psU8) in[col];
    1050                     }
    1051                 }
    1052             };
    1053             break;
    1054         case PS_TYPE_U32: {
    1055                 psU32 *in;
    1056                 psU8 *out;
    1057                 for (int row = 0; row < numRows; row++) {
    1058                     in = input->data.U32[row];
    1059                     out = output->data.U8[row];
    1060                     for (int col = 0; col < numCols; col++) {
    1061                         out[col] = (psU8) in[col];
    1062                     }
    1063                 }
    1064             };
    1065             break;
    1066         case PS_TYPE_U64: {
    1067                 psU64 *in;
    1068                 psU8 *out;
    1069                 for (int row = 0; row < numRows; row++) {
    1070                     in = input->data.U64[row];
    1071                     out = output->data.U8[row];
    1072                     for (int col = 0; col < numCols; col++) {
    1073                         out[col] = (psU8) in[col];
    1074                     }
    1075                 }
    1076             };
    1077             break;
    1078         case PS_TYPE_F32: {
    1079                 psF32 *in;
    1080                 psU8 *out;
    1081                 for (int row = 0; row < numRows; row++) {
    1082                     in = input->data.F32[row];
    1083                     out = output->data.U8[row];
    1084                     for (int col = 0; col < numCols; col++) {
    1085                         out[col] = (psU8) in[col];
    1086                     }
    1087                 }
    1088             };
    1089             break;
    1090         case PS_TYPE_F64: {
    1091                 psF64 *in;
    1092                 psU8 *out;
    1093                 for (int row = 0; row < numRows; row++) {
    1094                     in = input->data.F64[row];
    1095                     out = output->data.U8[row];
    1096                     for (int col = 0; col < numCols; col++) {
    1097                         out[col] = (psU8) in[col];
    1098                     }
    1099                 }
    1100             };
    1101             break;
    1102         case PS_TYPE_C32: {
    1103                 psC32 *in;
    1104                 psU8 *out;
    1105                 for (int row = 0; row < numRows; row++) {
    1106                     in = input->data.C32[row];
    1107                     out = output->data.U8[row];
    1108                     for (int col = 0; col < numCols; col++) {
    1109                         out[col] = (psU8) in[col];
    1110                     }
    1111                 }
    1112             };
    1113             break;
    1114         case PS_TYPE_PTR:
    1115             psError (__func__, "Can't copy image from a matrix of pointers.");
    1116             psFree (output);
    1117             return ((void *) 0);
    1118         default:
    1119             break;
    1120         };
     373        PSIMAGE_COPY_CASE(output,U8);
    1121374        break;
    1122375    case PS_TYPE_U16:
    1123         switch (input->type.type) {
    1124         case PS_TYPE_S8: {
    1125                 psS8 *in;
    1126                 psU16 *out;
    1127                 for (int row = 0; row < numRows; row++) {
    1128                     in = input->data.S8[row];
    1129                     out = output->data.U16[row];
    1130                     for (int col = 0; col < numCols; col++) {
    1131                         out[col] = (psU16) in[col];
    1132                     }
    1133                 }
    1134             };
    1135             break;
    1136         case PS_TYPE_S16: {
    1137                 psS16 *in;
    1138                 psU16 *out;
    1139                 for (int row = 0; row < numRows; row++) {
    1140                     in = input->data.S16[row];
    1141                     out = output->data.U16[row];
    1142                     for (int col = 0; col < numCols; col++) {
    1143                         out[col] = (psU16) in[col];
    1144                     }
    1145                 }
    1146             };
    1147             break;
    1148         case PS_TYPE_S32: {
    1149                 psS32 *in;
    1150                 psU16 *out;
    1151                 for (int row = 0; row < numRows; row++) {
    1152                     in = input->data.S32[row];
    1153                     out = output->data.U16[row];
    1154                     for (int col = 0; col < numCols; col++) {
    1155                         out[col] = (psU16) in[col];
    1156                     }
    1157                 }
    1158             };
    1159             break;
    1160         case PS_TYPE_S64: {
    1161                 psS64 *in;
    1162                 psU16 *out;
    1163                 for (int row = 0; row < numRows; row++) {
    1164                     in = input->data.S64[row];
    1165                     out = output->data.U16[row];
    1166                     for (int col = 0; col < numCols; col++) {
    1167                         out[col] = (psU16) in[col];
    1168                     }
    1169                 }
    1170             };
    1171             break;
    1172         case PS_TYPE_U8: {
    1173                 psU8 *in;
    1174                 psU16 *out;
    1175                 for (int row = 0; row < numRows; row++) {
    1176                     in = input->data.U8[row];
    1177                     out = output->data.U16[row];
    1178                     for (int col = 0; col < numCols; col++) {
    1179                         out[col] = (psU16) in[col];
    1180                     }
    1181                 }
    1182             };
    1183             break;
    1184         case PS_TYPE_U16: {
    1185                 psU16 *in;
    1186                 psU16 *out;
    1187                 for (int row = 0; row < numRows; row++) {
    1188                     in = input->data.U16[row];
    1189                     out = output->data.U16[row];
    1190                     for (int col = 0; col < numCols; col++) {
    1191                         out[col] = (psU16) in[col];
    1192                     }
    1193                 }
    1194             };
    1195             break;
    1196         case PS_TYPE_U32: {
    1197                 psU32 *in;
    1198                 psU16 *out;
    1199                 for (int row = 0; row < numRows; row++) {
    1200                     in = input->data.U32[row];
    1201                     out = output->data.U16[row];
    1202                     for (int col = 0; col < numCols; col++) {
    1203                         out[col] = (psU16) in[col];
    1204                     }
    1205                 }
    1206             };
    1207             break;
    1208         case PS_TYPE_U64: {
    1209                 psU64 *in;
    1210                 psU16 *out;
    1211                 for (int row = 0; row < numRows; row++) {
    1212                     in = input->data.U64[row];
    1213                     out = output->data.U16[row];
    1214                     for (int col = 0; col < numCols; col++) {
    1215                         out[col] = (psU16) in[col];
    1216                     }
    1217                 }
    1218             };
    1219             break;
    1220         case PS_TYPE_F32: {
    1221                 psF32 *in;
    1222                 psU16 *out;
    1223                 for (int row = 0; row < numRows; row++) {
    1224                     in = input->data.F32[row];
    1225                     out = output->data.U16[row];
    1226                     for (int col = 0; col < numCols; col++) {
    1227                         out[col] = (psU16) in[col];
    1228                     }
    1229                 }
    1230             };
    1231             break;
    1232         case PS_TYPE_F64: {
    1233                 psF64 *in;
    1234                 psU16 *out;
    1235                 for (int row = 0; row < numRows; row++) {
    1236                     in = input->data.F64[row];
    1237                     out = output->data.U16[row];
    1238                     for (int col = 0; col < numCols; col++) {
    1239                         out[col] = (psU16) in[col];
    1240                     }
    1241                 }
    1242             };
    1243             break;
    1244         case PS_TYPE_C32: {
    1245                 psC32 *in;
    1246                 psU16 *out;
    1247                 for (int row = 0; row < numRows; row++) {
    1248                     in = input->data.C32[row];
    1249                     out = output->data.U16[row];
    1250                     for (int col = 0; col < numCols; col++) {
    1251                         out[col] = (psU16) in[col];
    1252                     }
    1253                 }
    1254             };
    1255             break;
    1256         case PS_TYPE_PTR:
    1257             psError (__func__, "Can't copy image from a matrix of pointers.");
    1258             psFree (output);
    1259             return ((void *) 0);
    1260         default:
    1261             break;
    1262         };
     376        PSIMAGE_COPY_CASE(output,U16);
    1263377        break;
    1264378    case PS_TYPE_U32:
    1265         switch (input->type.type) {
    1266         case PS_TYPE_S8: {
    1267                 psS8 *in;
    1268                 psU32 *out;
    1269                 for (int row = 0; row < numRows; row++) {
    1270                     in = input->data.S8[row];
    1271                     out = output->data.U32[row];
    1272                     for (int col = 0; col < numCols; col++) {
    1273                         out[col] = (psU32) in[col];
    1274                     }
    1275                 }
    1276             };
    1277             break;
    1278         case PS_TYPE_S16: {
    1279                 psS16 *in;
    1280                 psU32 *out;
    1281                 for (int row = 0; row < numRows; row++) {
    1282                     in = input->data.S16[row];
    1283                     out = output->data.U32[row];
    1284                     for (int col = 0; col < numCols; col++) {
    1285                         out[col] = (psU32) in[col];
    1286                     }
    1287                 }
    1288             };
    1289             break;
    1290         case PS_TYPE_S32: {
    1291                 psS32 *in;
    1292                 psU32 *out;
    1293                 for (int row = 0; row < numRows; row++) {
    1294                     in = input->data.S32[row];
    1295                     out = output->data.U32[row];
    1296                     for (int col = 0; col < numCols; col++) {
    1297                         out[col] = (psU32) in[col];
    1298                     }
    1299                 }
    1300             };
    1301             break;
    1302         case PS_TYPE_S64: {
    1303                 psS64 *in;
    1304                 psU32 *out;
    1305                 for (int row = 0; row < numRows; row++) {
    1306                     in = input->data.S64[row];
    1307                     out = output->data.U32[row];
    1308                     for (int col = 0; col < numCols; col++) {
    1309                         out[col] = (psU32) in[col];
    1310                     }
    1311                 }
    1312             };
    1313             break;
    1314         case PS_TYPE_U8: {
    1315                 psU8 *in;
    1316                 psU32 *out;
    1317                 for (int row = 0; row < numRows; row++) {
    1318                     in = input->data.U8[row];
    1319                     out = output->data.U32[row];
    1320                     for (int col = 0; col < numCols; col++) {
    1321                         out[col] = (psU32) in[col];
    1322                     }
    1323                 }
    1324             };
    1325             break;
    1326         case PS_TYPE_U16: {
    1327                 psU16 *in;
    1328                 psU32 *out;
    1329                 for (int row = 0; row < numRows; row++) {
    1330                     in = input->data.U16[row];
    1331                     out = output->data.U32[row];
    1332                     for (int col = 0; col < numCols; col++) {
    1333                         out[col] = (psU32) in[col];
    1334                     }
    1335                 }
    1336             };
    1337             break;
    1338         case PS_TYPE_U32: {
    1339                 psU32 *in;
    1340                 psU32 *out;
    1341                 for (int row = 0; row < numRows; row++) {
    1342                     in = input->data.U32[row];
    1343                     out = output->data.U32[row];
    1344                     for (int col = 0; col < numCols; col++) {
    1345                         out[col] = (psU32) in[col];
    1346                     }
    1347                 }
    1348             };
    1349             break;
    1350         case PS_TYPE_U64: {
    1351                 psU64 *in;
    1352                 psU32 *out;
    1353                 for (int row = 0; row < numRows; row++) {
    1354                     in = input->data.U64[row];
    1355                     out = output->data.U32[row];
    1356                     for (int col = 0; col < numCols; col++) {
    1357                         out[col] = (psU32) in[col];
    1358                     }
    1359                 }
    1360             };
    1361             break;
    1362         case PS_TYPE_F32: {
    1363                 psF32 *in;
    1364                 psU32 *out;
    1365                 for (int row = 0; row < numRows; row++) {
    1366                     in = input->data.F32[row];
    1367                     out = output->data.U32[row];
    1368                     for (int col = 0; col < numCols; col++) {
    1369                         out[col] = (psU32) in[col];
    1370                     }
    1371                 }
    1372             };
    1373             break;
    1374         case PS_TYPE_F64: {
    1375                 psF64 *in;
    1376                 psU32 *out;
    1377                 for (int row = 0; row < numRows; row++) {
    1378                     in = input->data.F64[row];
    1379                     out = output->data.U32[row];
    1380                     for (int col = 0; col < numCols; col++) {
    1381                         out[col] = (psU32) in[col];
    1382                     }
    1383                 }
    1384             };
    1385             break;
    1386         case PS_TYPE_C32: {
    1387                 psC32 *in;
    1388                 psU32 *out;
    1389                 for (int row = 0; row < numRows; row++) {
    1390                     in = input->data.C32[row];
    1391                     out = output->data.U32[row];
    1392                     for (int col = 0; col < numCols; col++) {
    1393                         out[col] = (psU32) in[col];
    1394                     }
    1395                 }
    1396             };
    1397             break;
    1398         case PS_TYPE_PTR:
    1399             psError (__func__, "Can't copy image from a matrix of pointers.");
    1400             psFree (output);
    1401             return ((void *) 0);
    1402         default:
    1403             break;
    1404         };
     379        PSIMAGE_COPY_CASE(output,U32);
    1405380        break;
    1406381    case PS_TYPE_U64:
    1407         switch (input->type.type) {
    1408         case PS_TYPE_S8: {
    1409                 psS8 *in;
    1410                 psU64 *out;
    1411                 for (int row = 0; row < numRows; row++) {
    1412                     in = input->data.S8[row];
    1413                     out = output->data.U64[row];
    1414                     for (int col = 0; col < numCols; col++) {
    1415                         out[col] = (psU64) in[col];
    1416                     }
    1417                 }
    1418             };
    1419             break;
    1420         case PS_TYPE_S16: {
    1421                 psS16 *in;
    1422                 psU64 *out;
    1423                 for (int row = 0; row < numRows; row++) {
    1424                     in = input->data.S16[row];
    1425                     out = output->data.U64[row];
    1426                     for (int col = 0; col < numCols; col++) {
    1427                         out[col] = (psU64) in[col];
    1428                     }
    1429                 }
    1430             };
    1431             break;
    1432         case PS_TYPE_S32: {
    1433                 psS32 *in;
    1434                 psU64 *out;
    1435                 for (int row = 0; row < numRows; row++) {
    1436                     in = input->data.S32[row];
    1437                     out = output->data.U64[row];
    1438                     for (int col = 0; col < numCols; col++) {
    1439                         out[col] = (psU64) in[col];
    1440                     }
    1441                 }
    1442             };
    1443             break;
    1444         case PS_TYPE_S64: {
    1445                 psS64 *in;
    1446                 psU64 *out;
    1447                 for (int row = 0; row < numRows; row++) {
    1448                     in = input->data.S64[row];
    1449                     out = output->data.U64[row];
    1450                     for (int col = 0; col < numCols; col++) {
    1451                         out[col] = (psU64) in[col];
    1452                     }
    1453                 }
    1454             };
    1455             break;
    1456         case PS_TYPE_U8: {
    1457                 psU8 *in;
    1458                 psU64 *out;
    1459                 for (int row = 0; row < numRows; row++) {
    1460                     in = input->data.U8[row];
    1461                     out = output->data.U64[row];
    1462                     for (int col = 0; col < numCols; col++) {
    1463                         out[col] = (psU64) in[col];
    1464                     }
    1465                 }
    1466             };
    1467             break;
    1468         case PS_TYPE_U16: {
    1469                 psU16 *in;
    1470                 psU64 *out;
    1471                 for (int row = 0; row < numRows; row++) {
    1472                     in = input->data.U16[row];
    1473                     out = output->data.U64[row];
    1474                     for (int col = 0; col < numCols; col++) {
    1475                         out[col] = (psU64) in[col];
    1476                     }
    1477                 }
    1478             };
    1479             break;
    1480         case PS_TYPE_U32: {
    1481                 psU32 *in;
    1482                 psU64 *out;
    1483                 for (int row = 0; row < numRows; row++) {
    1484                     in = input->data.U32[row];
    1485                     out = output->data.U64[row];
    1486                     for (int col = 0; col < numCols; col++) {
    1487                         out[col] = (psU64) in[col];
    1488                     }
    1489                 }
    1490             };
    1491             break;
    1492         case PS_TYPE_U64: {
    1493                 psU64 *in;
    1494                 psU64 *out;
    1495                 for (int row = 0; row < numRows; row++) {
    1496                     in = input->data.U64[row];
    1497                     out = output->data.U64[row];
    1498                     for (int col = 0; col < numCols; col++) {
    1499                         out[col] = (psU64) in[col];
    1500                     }
    1501                 }
    1502             };
    1503             break;
    1504         case PS_TYPE_F32: {
    1505                 psF32 *in;
    1506                 psU64 *out;
    1507                 for (int row = 0; row < numRows; row++) {
    1508                     in = input->data.F32[row];
    1509                     out = output->data.U64[row];
    1510                     for (int col = 0; col < numCols; col++) {
    1511                         out[col] = (psU64) in[col];
    1512                     }
    1513                 }
    1514             };
    1515             break;
    1516         case PS_TYPE_F64: {
    1517                 psF64 *in;
    1518                 psU64 *out;
    1519                 for (int row = 0; row < numRows; row++) {
    1520                     in = input->data.F64[row];
    1521                     out = output->data.U64[row];
    1522                     for (int col = 0; col < numCols; col++) {
    1523                         out[col] = (psU64) in[col];
    1524                     }
    1525                 }
    1526             };
    1527             break;
    1528         case PS_TYPE_C32: {
    1529                 psC32 *in;
    1530                 psU64 *out;
    1531                 for (int row = 0; row < numRows; row++) {
    1532                     in = input->data.C32[row];
    1533                     out = output->data.U64[row];
    1534                     for (int col = 0; col < numCols; col++) {
    1535                         out[col] = (psU64) in[col];
    1536                     }
    1537                 }
    1538             };
    1539             break;
    1540         case PS_TYPE_PTR:
    1541             psError (__func__, "Can't copy image from a matrix of pointers.");
    1542             psFree (output);
    1543             return ((void *) 0);
    1544         default:
    1545             break;
    1546         };
     382        PSIMAGE_COPY_CASE(output,U64);
    1547383        break;
    1548384    case PS_TYPE_F32:
    1549         switch (input->type.type) {
    1550         case PS_TYPE_S8: {
    1551                 psS8 *in;
    1552                 psF32 *out;
    1553                 for (int row = 0; row < numRows; row++) {
    1554                     in = input->data.S8[row];
    1555                     out = output->data.F32[row];
    1556                     for (int col = 0; col < numCols; col++) {
    1557                         out[col] = (psF32) in[col];
    1558                     }
    1559                 }
    1560             };
    1561             break;
    1562         case PS_TYPE_S16: {
    1563                 psS16 *in;
    1564                 psF32 *out;
    1565                 for (int row = 0; row < numRows; row++) {
    1566                     in = input->data.S16[row];
    1567                     out = output->data.F32[row];
    1568                     for (int col = 0; col < numCols; col++) {
    1569                         out[col] = (psF32) in[col];
    1570                     }
    1571                 }
    1572             };
    1573             break;
    1574         case PS_TYPE_S32: {
    1575                 psS32 *in;
    1576                 psF32 *out;
    1577                 for (int row = 0; row < numRows; row++) {
    1578                     in = input->data.S32[row];
    1579                     out = output->data.F32[row];
    1580                     for (int col = 0; col < numCols; col++) {
    1581                         out[col] = (psF32) in[col];
    1582                     }
    1583                 }
    1584             };
    1585             break;
    1586         case PS_TYPE_S64: {
    1587                 psS64 *in;
    1588                 psF32 *out;
    1589                 for (int row = 0; row < numRows; row++) {
    1590                     in = input->data.S64[row];
    1591                     out = output->data.F32[row];
    1592                     for (int col = 0; col < numCols; col++) {
    1593                         out[col] = (psF32) in[col];
    1594                     }
    1595                 }
    1596             };
    1597             break;
    1598         case PS_TYPE_U8: {
    1599                 psU8 *in;
    1600                 psF32 *out;
    1601                 for (int row = 0; row < numRows; row++) {
    1602                     in = input->data.U8[row];
    1603                     out = output->data.F32[row];
    1604                     for (int col = 0; col < numCols; col++) {
    1605                         out[col] = (psF32) in[col];
    1606                     }
    1607                 }
    1608             };
    1609             break;
    1610         case PS_TYPE_U16: {
    1611                 psU16 *in;
    1612                 psF32 *out;
    1613                 for (int row = 0; row < numRows; row++) {
    1614                     in = input->data.U16[row];
    1615                     out = output->data.F32[row];
    1616                     for (int col = 0; col < numCols; col++) {
    1617                         out[col] = (psF32) in[col];
    1618                     }
    1619                 }
    1620             };
    1621             break;
    1622         case PS_TYPE_U32: {
    1623                 psU32 *in;
    1624                 psF32 *out;
    1625                 for (int row = 0; row < numRows; row++) {
    1626                     in = input->data.U32[row];
    1627                     out = output->data.F32[row];
    1628                     for (int col = 0; col < numCols; col++) {
    1629                         out[col] = (psF32) in[col];
    1630                     }
    1631                 }
    1632             };
    1633             break;
    1634         case PS_TYPE_U64: {
    1635                 psU64 *in;
    1636                 psF32 *out;
    1637                 for (int row = 0; row < numRows; row++) {
    1638                     in = input->data.U64[row];
    1639                     out = output->data.F32[row];
    1640                     for (int col = 0; col < numCols; col++) {
    1641                         out[col] = (psF32) in[col];
    1642                     }
    1643                 }
    1644             };
    1645             break;
    1646         case PS_TYPE_F32: {
    1647                 psF32 *in;
    1648                 psF32 *out;
    1649                 for (int row = 0; row < numRows; row++) {
    1650                     in = input->data.F32[row];
    1651                     out = output->data.F32[row];
    1652                     for (int col = 0; col < numCols; col++) {
    1653                         out[col] = (psF32) in[col];
    1654                     }
    1655                 }
    1656             };
    1657             break;
    1658         case PS_TYPE_F64: {
    1659                 psF64 *in;
    1660                 psF32 *out;
    1661                 for (int row = 0; row < numRows; row++) {
    1662                     in = input->data.F64[row];
    1663                     out = output->data.F32[row];
    1664                     for (int col = 0; col < numCols; col++) {
    1665                         out[col] = (psF32) in[col];
    1666                     }
    1667                 }
    1668             };
    1669             break;
    1670         case PS_TYPE_C32: {
    1671                 psC32 *in;
    1672                 psF32 *out;
    1673                 for (int row = 0; row < numRows; row++) {
    1674                     in = input->data.C32[row];
    1675                     out = output->data.F32[row];
    1676                     for (int col = 0; col < numCols; col++) {
    1677                         out[col] = (psF32) in[col];
    1678                     }
    1679                 }
    1680             };
    1681             break;
    1682         case PS_TYPE_PTR:
    1683             psError (__func__, "Can't copy image from a matrix of pointers.");
    1684             psFree (output);
    1685             return ((void *) 0);
    1686         default:
    1687             break;
    1688         };
     385        PSIMAGE_COPY_CASE(output,F32);
    1689386        break;
    1690387    case PS_TYPE_F64:
    1691         switch (input->type.type) {
    1692         case PS_TYPE_S8: {
    1693                 psS8 *in;
    1694                 psF64 *out;
    1695                 for (int row = 0; row < numRows; row++) {
    1696                     in = input->data.S8[row];
    1697                     out = output->data.F64[row];
    1698                     for (int col = 0; col < numCols; col++) {
    1699                         out[col] = (psF64) in[col];
    1700                     }
    1701                 }
    1702             };
    1703             break;
    1704         case PS_TYPE_S16: {
    1705                 psS16 *in;
    1706                 psF64 *out;
    1707                 for (int row = 0; row < numRows; row++) {
    1708                     in = input->data.S16[row];
    1709                     out = output->data.F64[row];
    1710                     for (int col = 0; col < numCols; col++) {
    1711                         out[col] = (psF64) in[col];
    1712                     }
    1713                 }
    1714             };
    1715             break;
    1716         case PS_TYPE_S32: {
    1717                 psS32 *in;
    1718                 psF64 *out;
    1719                 for (int row = 0; row < numRows; row++) {
    1720                     in = input->data.S32[row];
    1721                     out = output->data.F64[row];
    1722                     for (int col = 0; col < numCols; col++) {
    1723                         out[col] = (psF64) in[col];
    1724                     }
    1725                 }
    1726             };
    1727             break;
    1728         case PS_TYPE_S64: {
    1729                 psS64 *in;
    1730                 psF64 *out;
    1731                 for (int row = 0; row < numRows; row++) {
    1732                     in = input->data.S64[row];
    1733                     out = output->data.F64[row];
    1734                     for (int col = 0; col < numCols; col++) {
    1735                         out[col] = (psF64) in[col];
    1736                     }
    1737                 }
    1738             };
    1739             break;
    1740         case PS_TYPE_U8: {
    1741                 psU8 *in;
    1742                 psF64 *out;
    1743                 for (int row = 0; row < numRows; row++) {
    1744                     in = input->data.U8[row];
    1745                     out = output->data.F64[row];
    1746                     for (int col = 0; col < numCols; col++) {
    1747                         out[col] = (psF64) in[col];
    1748                     }
    1749                 }
    1750             };
    1751             break;
    1752         case PS_TYPE_U16: {
    1753                 psU16 *in;
    1754                 psF64 *out;
    1755                 for (int row = 0; row < numRows; row++) {
    1756                     in = input->data.U16[row];
    1757                     out = output->data.F64[row];
    1758                     for (int col = 0; col < numCols; col++) {
    1759                         out[col] = (psF64) in[col];
    1760                     }
    1761                 }
    1762             };
    1763             break;
    1764         case PS_TYPE_U32: {
    1765                 psU32 *in;
    1766                 psF64 *out;
    1767                 for (int row = 0; row < numRows; row++) {
    1768                     in = input->data.U32[row];
    1769                     out = output->data.F64[row];
    1770                     for (int col = 0; col < numCols; col++) {
    1771                         out[col] = (psF64) in[col];
    1772                     }
    1773                 }
    1774             };
    1775             break;
    1776         case PS_TYPE_U64: {
    1777                 psU64 *in;
    1778                 psF64 *out;
    1779                 for (int row = 0; row < numRows; row++) {
    1780                     in = input->data.U64[row];
    1781                     out = output->data.F64[row];
    1782                     for (int col = 0; col < numCols; col++) {
    1783                         out[col] = (psF64) in[col];
    1784                     }
    1785                 }
    1786             };
    1787             break;
    1788         case PS_TYPE_F32: {
    1789                 psF32 *in;
    1790                 psF64 *out;
    1791                 for (int row = 0; row < numRows; row++) {
    1792                     in = input->data.F32[row];
    1793                     out = output->data.F64[row];
    1794                     for (int col = 0; col < numCols; col++) {
    1795                         out[col] = (psF64) in[col];
    1796                     }
    1797                 }
    1798             };
    1799             break;
    1800         case PS_TYPE_F64: {
    1801                 psF64 *in;
    1802                 psF64 *out;
    1803                 for (int row = 0; row < numRows; row++) {
    1804                     in = input->data.F64[row];
    1805                     out = output->data.F64[row];
    1806                     for (int col = 0; col < numCols; col++) {
    1807                         out[col] = (psF64) in[col];
    1808                     }
    1809                 }
    1810             };
    1811             break;
    1812         case PS_TYPE_C32: {
    1813                 psC32 *in;
    1814                 psF64 *out;
    1815                 for (int row = 0; row < numRows; row++) {
    1816                     in = input->data.C32[row];
    1817                     out = output->data.F64[row];
    1818                     for (int col = 0; col < numCols; col++) {
    1819                         out[col] = (psF64) in[col];
    1820                     }
    1821                 }
    1822             };
    1823             break;
    1824         case PS_TYPE_PTR:
    1825             psError (__func__, "Can't copy image from a matrix of pointers.");
    1826             psFree (output);
    1827             return ((void *) 0);
    1828         default:
    1829             break;
    1830         };
     388        PSIMAGE_COPY_CASE(output,F64);
    1831389        break;
    1832390    case PS_TYPE_C32:
    1833         switch (input->type.type) {
    1834         case PS_TYPE_S8: {
    1835                 psS8 *in;
    1836                 psC32 *out;
    1837                 for (int row = 0; row < numRows; row++) {
    1838                     in = input->data.S8[row];
    1839                     out = output->data.C32[row];
    1840                     for (int col = 0; col < numCols; col++) {
    1841                         out[col] = (psC32) in[col];
    1842                     }
    1843                 }
    1844             };
    1845             break;
    1846         case PS_TYPE_S16: {
    1847                 psS16 *in;
    1848                 psC32 *out;
    1849                 for (int row = 0; row < numRows; row++) {
    1850                     in = input->data.S16[row];
    1851                     out = output->data.C32[row];
    1852                     for (int col = 0; col < numCols; col++) {
    1853                         out[col] = (psC32) in[col];
    1854                     }
    1855                 }
    1856             };
    1857             break;
    1858         case PS_TYPE_S32: {
    1859                 psS32 *in;
    1860                 psC32 *out;
    1861                 for (int row = 0; row < numRows; row++) {
    1862                     in = input->data.S32[row];
    1863                     out = output->data.C32[row];
    1864                     for (int col = 0; col < numCols; col++) {
    1865                         out[col] = (psC32) in[col];
    1866                     }
    1867                 }
    1868             };
    1869             break;
    1870         case PS_TYPE_S64: {
    1871                 psS64 *in;
    1872                 psC32 *out;
    1873                 for (int row = 0; row < numRows; row++) {
    1874                     in = input->data.S64[row];
    1875                     out = output->data.C32[row];
    1876                     for (int col = 0; col < numCols; col++) {
    1877                         out[col] = (psC32) in[col];
    1878                     }
    1879                 }
    1880             };
    1881             break;
    1882         case PS_TYPE_U8: {
    1883                 psU8 *in;
    1884                 psC32 *out;
    1885                 for (int row = 0; row < numRows; row++) {
    1886                     in = input->data.U8[row];
    1887                     out = output->data.C32[row];
    1888                     for (int col = 0; col < numCols; col++) {
    1889                         out[col] = (psC32) in[col];
    1890                     }
    1891                 }
    1892             };
    1893             break;
    1894         case PS_TYPE_U16: {
    1895                 psU16 *in;
    1896                 psC32 *out;
    1897                 for (int row = 0; row < numRows; row++) {
    1898                     in = input->data.U16[row];
    1899                     out = output->data.C32[row];
    1900                     for (int col = 0; col < numCols; col++) {
    1901                         out[col] = (psC32) in[col];
    1902                     }
    1903                 }
    1904             };
    1905             break;
    1906         case PS_TYPE_U32: {
    1907                 psU32 *in;
    1908                 psC32 *out;
    1909                 for (int row = 0; row < numRows; row++) {
    1910                     in = input->data.U32[row];
    1911                     out = output->data.C32[row];
    1912                     for (int col = 0; col < numCols; col++) {
    1913                         out[col] = (psC32) in[col];
    1914                     }
    1915                 }
    1916             };
    1917             break;
    1918         case PS_TYPE_U64: {
    1919                 psU64 *in;
    1920                 psC32 *out;
    1921                 for (int row = 0; row < numRows; row++) {
    1922                     in = input->data.U64[row];
    1923                     out = output->data.C32[row];
    1924                     for (int col = 0; col < numCols; col++) {
    1925                         out[col] = (psC32) in[col];
    1926                     }
    1927                 }
    1928             };
    1929             break;
    1930         case PS_TYPE_F32: {
    1931                 psF32 *in;
    1932                 psC32 *out;
    1933                 for (int row = 0; row < numRows; row++) {
    1934                     in = input->data.F32[row];
    1935                     out = output->data.C32[row];
    1936                     for (int col = 0; col < numCols; col++) {
    1937                         out[col] = (psC32) in[col];
    1938                     }
    1939                 }
    1940             };
    1941             break;
    1942         case PS_TYPE_F64: {
    1943                 psF64 *in;
    1944                 psC32 *out;
    1945                 for (int row = 0; row < numRows; row++) {
    1946                     in = input->data.F64[row];
    1947                     out = output->data.C32[row];
    1948                     for (int col = 0; col < numCols; col++) {
    1949                         out[col] = (psC32) in[col];
    1950                     }
    1951                 }
    1952             };
    1953             break;
    1954         case PS_TYPE_C32: {
    1955                 psC32 *in;
    1956                 psC32 *out;
    1957                 for (int row = 0; row < numRows; row++) {
    1958                     in = input->data.C32[row];
    1959                     out = output->data.C32[row];
    1960                     for (int col = 0; col < numCols; col++) {
    1961                         out[col] = (psC32) in[col];
    1962                     }
    1963                 }
    1964             };
    1965             break;
    1966         case PS_TYPE_PTR:
    1967             psError (__func__, "Can't copy image from a matrix of pointers.");
    1968             psFree (output);
    1969             return ((void *) 0);
    1970         default:
    1971             break;
    1972         };
     391        PSIMAGE_COPY_CASE(output,C32);
    1973392        break;
    1974393    case PS_TYPE_C64:
    1975         switch (input->type.type) {
    1976         case PS_TYPE_S8: {
    1977                 psS8 *in;
    1978                 psC64 *out;
    1979                 for (int row = 0; row < numRows; row++) {
    1980                     in = input->data.S8[row];
    1981                     out = output->data.C64[row];
    1982                     for (int col = 0; col < numCols; col++) {
    1983                         out[col] = (psC64) in[col];
    1984                     }
    1985                 }
    1986             };
    1987             break;
    1988         case PS_TYPE_S16: {
    1989                 psS16 *in;
    1990                 psC64 *out;
    1991                 for (int row = 0; row < numRows; row++) {
    1992                     in = input->data.S16[row];
    1993                     out = output->data.C64[row];
    1994                     for (int col = 0; col < numCols; col++) {
    1995                         out[col] = (psC64) in[col];
    1996                     }
    1997                 }
    1998             };
    1999             break;
    2000         case PS_TYPE_S32: {
    2001                 psS32 *in;
    2002                 psC64 *out;
    2003                 for (int row = 0; row < numRows; row++) {
    2004                     in = input->data.S32[row];
    2005                     out = output->data.C64[row];
    2006                     for (int col = 0; col < numCols; col++) {
    2007                         out[col] = (psC64) in[col];
    2008                     }
    2009                 }
    2010             };
    2011             break;
    2012         case PS_TYPE_S64: {
    2013                 psS64 *in;
    2014                 psC64 *out;
    2015                 for (int row = 0; row < numRows; row++) {
    2016                     in = input->data.S64[row];
    2017                     out = output->data.C64[row];
    2018                     for (int col = 0; col < numCols; col++) {
    2019                         out[col] = (psC64) in[col];
    2020                     }
    2021                 }
    2022             };
    2023             break;
    2024         case PS_TYPE_U8: {
    2025                 psU8 *in;
    2026                 psC64 *out;
    2027                 for (int row = 0; row < numRows; row++) {
    2028                     in = input->data.U8[row];
    2029                     out = output->data.C64[row];
    2030                     for (int col = 0; col < numCols; col++) {
    2031                         out[col] = (psC64) in[col];
    2032                     }
    2033                 }
    2034             };
    2035             break;
    2036         case PS_TYPE_U16: {
    2037                 psU16 *in;
    2038                 psC64 *out;
    2039                 for (int row = 0; row < numRows; row++) {
    2040                     in = input->data.U16[row];
    2041                     out = output->data.C64[row];
    2042                     for (int col = 0; col < numCols; col++) {
    2043                         out[col] = (psC64) in[col];
    2044                     }
    2045                 }
    2046             };
    2047             break;
    2048         case PS_TYPE_U32: {
    2049                 psU32 *in;
    2050                 psC64 *out;
    2051                 for (int row = 0; row < numRows; row++) {
    2052                     in = input->data.U32[row];
    2053                     out = output->data.C64[row];
    2054                     for (int col = 0; col < numCols; col++) {
    2055                         out[col] = (psC64) in[col];
    2056                     }
    2057                 }
    2058             };
    2059             break;
    2060         case PS_TYPE_U64: {
    2061                 psU64 *in;
    2062                 psC64 *out;
    2063                 for (int row = 0; row < numRows; row++) {
    2064                     in = input->data.U64[row];
    2065                     out = output->data.C64[row];
    2066                     for (int col = 0; col < numCols; col++) {
    2067                         out[col] = (psC64) in[col];
    2068                     }
    2069                 }
    2070             };
    2071             break;
    2072         case PS_TYPE_F32: {
    2073                 psF32 *in;
    2074                 psC64 *out;
    2075                 for (int row = 0; row < numRows; row++) {
    2076                     in = input->data.F32[row];
    2077                     out = output->data.C64[row];
    2078                     for (int col = 0; col < numCols; col++) {
    2079                         out[col] = (psC64) in[col];
    2080                     }
    2081                 }
    2082             };
    2083             break;
    2084         case PS_TYPE_F64: {
    2085                 psF64 *in;
    2086                 psC64 *out;
    2087                 for (int row = 0; row < numRows; row++) {
    2088                     in = input->data.F64[row];
    2089                     out = output->data.C64[row];
    2090                     for (int col = 0; col < numCols; col++) {
    2091                         out[col] = (psC64) in[col];
    2092                     }
    2093                 }
    2094             };
    2095             break;
    2096         case PS_TYPE_C32: {
    2097                 psC32 *in;
    2098                 psC64 *out;
    2099                 for (int row = 0; row < numRows; row++) {
    2100                     in = input->data.C32[row];
    2101                     out = output->data.C64[row];
    2102                     for (int col = 0; col < numCols; col++) {
    2103                         out[col] = (psC64) in[col];
    2104                     }
    2105                 }
    2106             };
    2107             break;
    2108         case PS_TYPE_PTR:
    2109             psError (__func__, "Can't copy image from a matrix of pointers.");
    2110             psFree (output);
    2111             return ((void *) 0);
    2112         default:
    2113             break;
    2114         };
    2115         break;
    2116     case PS_TYPE_PTR:
    2117         psError (__func__, "Can't copy image into a matrix of pointers.");
    2118         psFree (output);
    2119         return ((void *) 0);
    2120     }
    2121 
     394        PSIMAGE_COPY_CASE(output,C64);
     395        break;
     396    default:
     397        break;
     398    }
    2122399    return output;
    2123400}
     
    2340617    }
    2341618
    2342     #endif
    2343 
    2344619    return 0;
    2345620}
Note: See TracChangeset for help on using the changeset viewer.