IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 27, 2004, 3:43:17 PM (22 years ago)
Author:
desonia
Message:

Bug #1066 - psImageOverlaySection shall return the number of pixels overlaid.

File:
1 edited

Legend:

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

    r2807 r2835  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-12-23 19:14:15 $
     12 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-12-28 01:42:28 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    195195    psU32 imageColLimit;
    196196    psElemType type;
     197    psU32 pixelsOverlaid = 0;
    197198
    198199    if (image == NULL || overlay == NULL) {
    199200        psError(PS_ERR_BAD_PARAMETER_NULL, true,
    200201                PS_ERRORTEXT_psImage_IMAGE_NULL);
    201         return 1;
     202        return pixelsOverlaid;
    202203    }
    203204
     
    205206        psError(PS_ERR_BAD_PARAMETER_NULL, true,
    206207                PS_ERRORTEXT_psImageManip_OPERATION_NULL);
    207         return 1;
     208        return pixelsOverlaid;
    208209    }
    209210
     
    218219                PS_ERRORTEXT_psImageManip_OVERLAY_TYPE_MISMATCH,
    219220                typeStrOverlay, typeStr);
    220         return 2;
     221        return pixelsOverlaid;
    221222    }
    222223
     
    238239                col0, imageColLimit, row0, imageRowLimit,
    239240                imageNumCols, imageNumRows);
    240         return 3;
    241     }
    242 
    243     switch (type) {
    244 
    245         #define psImageOverlayCase(DATATYPE) \
    246     case PS_TYPE_##DATATYPE: \
    247         for (psU32 row=row0;row<imageRowLimit;row++) { \
     241        return pixelsOverlaid;
     242    }
     243
     244
     245    #define psImageOverlayLoop(DATATYPE,OP) { \
     246        for (int row=row0;row<imageRowLimit;row++) { \
    248247            ps##DATATYPE* imageRow = image->data.DATATYPE[row]; \
    249248            ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-row0]; \
    250             for (psU32 col=col0;col<imageColLimit;col++) { \
    251                 switch (*op) { \
    252                 case '+': \
    253                     imageRow[col] += overlayRow[col-col0]; \
    254                     break; \
    255                 case '-': \
    256                     imageRow[col] -= overlayRow[col-col0]; \
    257                     break; \
    258                 case '*': \
    259                     imageRow[col] *= overlayRow[col-col0]; \
    260                     break; \
    261                 case '/': \
    262                     imageRow[col] /= overlayRow[col-col0]; \
    263                     break; \
    264                 case '=': \
    265                     imageRow[col] = overlayRow[col-col0]; \
    266                     break; \
    267                 default: \
    268                     psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
    269                             PS_ERRORTEXT_psImageManip_OVERLAY_OPERATOR_INVALID, \
    270                             op); \
    271                     return 5; \
    272                 } \
    273             } \
    274         } \
    275         break;
    276 
     249            for (int col=col0;col<imageColLimit;col++) { \
     250                imageRow[col] OP overlayRow[col-col0]; \
     251            } \
     252        } \
     253        pixelsOverlaid += (imageRowLimit - row0) * (imageColLimit - col0); \
     254    }
     255
     256    #define psImageOverlayCase(DATATYPE) \
     257case PS_TYPE_##DATATYPE: \
     258    switch (*op) { \
     259    case '+': \
     260        psImageOverlayLoop(DATATYPE,+=); \
     261        break; \
     262    case '-': \
     263        psImageOverlayLoop(DATATYPE,-=); \
     264        break; \
     265    case '*': \
     266        psImageOverlayLoop(DATATYPE,*=); \
     267        break; \
     268    case '/': \
     269        psImageOverlayLoop(DATATYPE,/=); \
     270        break; \
     271    case '=': \
     272        psImageOverlayLoop(DATATYPE,=); \
     273        break; \
     274    default: \
     275        psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
     276                PS_ERRORTEXT_psImageManip_OVERLAY_OPERATOR_INVALID, \
     277                op); \
     278        return pixelsOverlaid; \
     279    } \
     280    break;
     281
     282    switch (type) {
    277283        psImageOverlayCase(U8);
    278284        psImageOverlayCase(U16);
    279         //        psImageOverlayCase(U32);      Not a requirement
    280         //        psImageOverlayCase(U64);      Not a requirement
     285        psImageOverlayCase(U32);       // Not a requirement
     286        psImageOverlayCase(U64);       // Not a requirement
    281287        psImageOverlayCase(S8);
    282288        psImageOverlayCase(S16);
    283         //        psImageOverlayCase(S32);      Not a requirement
    284         //        psImageOverlayCase(S64);      Not a requirement
     289        psImageOverlayCase(S32);       // Not a requirement
     290        psImageOverlayCase(S64);       // Not a requirement
    285291        psImageOverlayCase(F32);
    286292        psImageOverlayCase(F64);
     
    294300                    PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED,
    295301                    typeStr);
    296             return 6;
    297         }
    298     }
    299 
    300     return 0;
     302            return pixelsOverlaid;
     303        }
     304    }
     305
     306    return pixelsOverlaid;
    301307}
    302308
     
    832838
    833839        /* optimized public domain rotation routine by Karl Lager
    834          * 
    835          * float cosT,sinT; 
    836          * cosT = cos(t); 
    837          * sinT = sin(t); 
    838          * for (y = min_y; y <= max_y; y++) { 
    839          *     x' = min_x * cosT + y * sinT + x1'; 
    840          *     y' = y * cosT - min_x * sinT + y1'; 
    841          *     for (x = min_x; x <= max_x; x++) { 
     840         *
     841         * float cosT,sinT;
     842         * cosT = cos(t);
     843         * sinT = sin(t);
     844         * for (y = min_y; y <= max_y; y++) {
     845         *     x' = min_x * cosT + y * sinT + x1';
     846         *     y' = y * cosT - min_x * sinT + y1';
     847         *     for (x = min_x; x <= max_x; x++) {
    842848         *         if (x', y') is in the bounds of the bitmap, get pixel
    843          *            (x', y') and plot the pixel to (x, y) on screen. 
    844          *         x' += cosT; 
    845          *         y' -= sinT; 
     849         *            (x', y') and plot the pixel to (x, y) on screen.
     850         *         x' += cosT;
     851         *         y' -= sinT;
    846852         *     }
    847          * } 
     853         * }
    848854         */
    849855
Note: See TracChangeset for help on using the changeset viewer.