IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5572


Ignore:
Timestamp:
Nov 22, 2005, 9:58:20 AM (21 years ago)
Author:
desonia
Message:

added type support to psImageInit.

Location:
trunk/psLib
Files:
2 edited

Legend:

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

    r5216 r5572  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.89 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-10-01 02:22:12 $
     11 *  @version $Revision: 1.90 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-11-22 19:58:16 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    220220
    221221    va_list argp;
    222     psU8  vU8;
    223     psF32 vF32;
    224     psF64 vF64;
    225     int temp;
    226222
    227223    if (image == NULL)
     
    231227
    232228    switch (image->type.type) {
    233     case PS_TYPE_U8:
    234         temp = va_arg (argp, psU32);
    235         if ( temp >= PS_MIN_U8 && temp <= PS_MAX_U8 )
    236             vU8 = temp;
    237         else {
    238             psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Error:  U8 Value out of Range.\n");
    239             return false;
     229        #define IMAGEINIT_INTCASE(TTT,NATIVETYPE) \
     230    case PS_TYPE_##TTT: { \
     231            NATIVETYPE temp = va_arg (argp, NATIVETYPE); \
     232            if ( temp < PS_MIN_##TTT || temp > PS_MAX_##TTT ) { \
     233                psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Error: Value out of Range.\n"); \
     234                return false; \
     235            } \
     236            ps##TTT value = temp; \
     237            for (int iy = 0; iy < image->numRows; iy++) { \
     238                ps##TTT *row = image->data.TTT[iy]; \
     239                for (int ix = 0; ix < image->numCols; ix++) { \
     240                    row[ix] = value; \
     241                } \
     242            } \
     243            return (true); \
    240244        }
    241         for (int iy = 0; iy < image->numRows; iy++) {
    242             for (int ix = 0; ix < image->numCols; ix++) {
    243                 image->data.U8[iy][ix] = vU8;
    244             }
     245
     246        IMAGEINIT_INTCASE(U8,unsigned int)
     247        IMAGEINIT_INTCASE(U16,unsigned int)
     248        IMAGEINIT_INTCASE(U32,unsigned int)
     249        IMAGEINIT_INTCASE(S8,int)
     250        IMAGEINIT_INTCASE(S16,int)
     251        IMAGEINIT_INTCASE(S32,int)
     252
     253        #define IMAGEINIT_LONGCASE(TTT,NATIVETYPE) \
     254    case PS_TYPE_##TTT: { \
     255            ps##TTT value = va_arg (argp, NATIVETYPE); \
     256            for (int iy = 0; iy < image->numRows; iy++) { \
     257                ps##TTT *row = image->data.TTT[iy]; \
     258                for (int ix = 0; ix < image->numCols; ix++) { \
     259                    row[ix] = value; \
     260                } \
     261            } \
     262            return (true); \
    245263        }
    246         return (true);
    247 
    248     case PS_TYPE_F32:
    249         vF32 = va_arg (argp, psF64);
    250 
    251         for (int iy = 0; iy < image->numRows; iy++) {
    252             for (int ix = 0; ix < image->numCols; ix++) {
    253                 image->data.F32[iy][ix] = vF32;
    254             }
     264
     265        IMAGEINIT_LONGCASE(U64,unsigned long)
     266        IMAGEINIT_LONGCASE(S64,long)
     267
     268        #define IMAGEINIT_FLOATCASE(TTT) \
     269    case PS_TYPE_##TTT: { \
     270            ps##TTT value = va_arg(argp, psF64); \
     271            \
     272            for (int iy = 0; iy < image->numRows; iy++) { \
     273                ps##TTT *row = image->data.TTT[iy]; \
     274                for (int ix = 0; ix < image->numCols; ix++) { \
     275                    row[ix] = value; \
     276                } \
     277            } \
     278            return (true); \
    255279        }
    256         return (true);
    257 
    258     case PS_TYPE_F64:
    259         vF64 = va_arg (argp, psF64);
    260 
    261         for (int iy = 0; iy < image->numRows; iy++) {
    262             for (int ix = 0; ix < image->numCols; ix++) {
    263                 image->data.F64[iy][ix] = vF64;
    264             }
    265         }
    266         return (true);
     280
     281        IMAGEINIT_FLOATCASE(F32)
     282        IMAGEINIT_FLOATCASE(F64)
    267283
    268284    default:
  • trunk/psLib/test/mathtypes/verified/tst_psImage.stderr

    r5174 r5572  
    122122
    123123<DATE><TIME>|<HOST>|E|psImageInit (FILE:LINENO)
    124     Error:  U8 Value out of Range.
     124    Error: Value out of Range.
    125125<DATE><TIME>|<HOST>|E|testImageInit (FILE:LINENO)
    126126    ImageInit failed.  U8 Case - 1x1
    127 <DATE><TIME>|<HOST>|E|psImageInit (FILE:LINENO)
    128     datatype 260 not defined in psImageInit
    129 <DATE><TIME>|<HOST>|E|testImageInit (FILE:LINENO)
    130     ImageInit failed.  S32 Case - 5x5
    131127
    132128---> TESTPOINT PASSED (psImage{psImageInit} | tst_psImage.c)
Note: See TracChangeset for help on using the changeset viewer.