IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7533


Ignore:
Timestamp:
Jun 13, 2006, 9:53:54 AM (20 years ago)
Author:
Paul Price
Message:

Fixing psImageGet, psImageSet: x,y were around the wrong way (!),
psImageSet declared the image as const (requiring a cast to set the
value). Macro-ized type cases.

File:
1 edited

Legend:

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

    r7524 r7533  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.105 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-06-12 20:43:16 $
     11 *  @version $Revision: 1.106 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-06-13 19:53:54 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    307307}
    308308
    309 bool psImageSet(const psImage *image,
     309bool psImageSet(psImage *image,
    310310                int x,
    311311                int y,
     
    361361    }
    362362
     363    #define IMAGE_SET_CASE(TYPE) \
     364case PS_TYPE_##TYPE: \
     365    image->data.TYPE[y][x] = value; \
     366    break;
     367
    363368    switch (image->type.type) {
    364     case PS_TYPE_U8:
    365         *(psU8*)&image->data.U8[x][y] = value;
    366         break;
    367     case PS_TYPE_U16:
    368         *(psU16*)&image->data.U16[x][y] = value;
    369         break;
    370     case PS_TYPE_U32:
    371         *(psU32*)&image->data.U32[x][y] = value;
    372         break;
    373     case PS_TYPE_U64:
    374         *(psU64*)&image->data.U64[x][y] = value;
    375         break;
    376     case PS_TYPE_S8:
    377         *(psS8*)&image->data.S8[x][y] = value;
    378         break;
    379     case PS_TYPE_S16:
    380         *(psS16*)&image->data.S16[x][y] = value;
    381         break;
    382     case PS_TYPE_S32:
    383         *(psS32*)&image->data.S32[x][y] = value;
    384         break;
    385     case PS_TYPE_S64:
    386         *(psS64*)&image->data.S64[x][y] = value;
    387         break;
    388     case PS_TYPE_F32:
    389         *(psF32*)&image->data.F32[x][y] = value;
    390         break;
    391     case PS_TYPE_F64:
    392         *(psF64*)&image->data.F64[x][y] = value;
    393         break;
    394     case PS_TYPE_C32:
    395         *(psC32*)&image->data.C32[x][y] = value;
    396         break;
    397     case PS_TYPE_C64:
    398         *(psC64*)&image->data.C64[x][y] = value;
    399         break;
     369        IMAGE_SET_CASE(U8);
     370        IMAGE_SET_CASE(U16);
     371        IMAGE_SET_CASE(U32);
     372        IMAGE_SET_CASE(U64);
     373        IMAGE_SET_CASE(S8);
     374        IMAGE_SET_CASE(S16);
     375        IMAGE_SET_CASE(S32);
     376        IMAGE_SET_CASE(S64);
     377        IMAGE_SET_CASE(F32);
     378        IMAGE_SET_CASE(F64);
     379        IMAGE_SET_CASE(C32);
     380        IMAGE_SET_CASE(C64);
    400381    default:
    401382        psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Invalid psImage Data Type\n");
     
    459440    }
    460441
     442    #define IMAGE_GET_CASE(TYPE) \
     443case PS_TYPE_##TYPE: \
     444    return image->data.TYPE[y][x];
    461445
    462446    switch (image->type.type) {
    463     case PS_TYPE_U8:
    464         return image->data.U8[x][y];
    465         break;
    466     case PS_TYPE_U16:
    467         return image->data.U16[x][y];
    468         break;
    469     case PS_TYPE_U32:
    470         return image->data.U32[x][y];
    471         break;
    472     case PS_TYPE_U64:
    473         return image->data.U64[x][y];
    474         break;
    475     case PS_TYPE_S8:
    476         return image->data.S8[x][y];
    477         break;
    478     case PS_TYPE_S16:
    479         return image->data.S16[x][y];
    480         break;
    481     case PS_TYPE_S32:
    482         return image->data.S32[x][y];
    483         break;
    484     case PS_TYPE_S64:
    485         return image->data.S64[x][y];
    486         break;
    487     case PS_TYPE_F32:
    488         return image->data.F32[x][y];
    489         break;
    490     case PS_TYPE_F64:
    491         return image->data.F64[x][y];
    492         break;
    493     case PS_TYPE_C32:
    494         return image->data.C32[x][y];
    495         break;
    496     case PS_TYPE_C64:
    497         return image->data.C64[x][y];
    498         break;
     447        IMAGE_GET_CASE(U8);
     448        IMAGE_GET_CASE(U16);
     449        IMAGE_GET_CASE(U32);
     450        IMAGE_GET_CASE(U64);
     451        IMAGE_GET_CASE(S8);
     452        IMAGE_GET_CASE(S16);
     453        IMAGE_GET_CASE(S32);
     454        IMAGE_GET_CASE(S64);
     455        IMAGE_GET_CASE(F32);
     456        IMAGE_GET_CASE(F64);
     457        IMAGE_GET_CASE(C32);
     458        IMAGE_GET_CASE(C64);
    499459    default:
    500460        psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Invalid psImage Data Type\n");
Note: See TracChangeset for help on using the changeset viewer.