IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 12, 2004, 4:40:13 PM (22 years ago)
Author:
desonia
Message:

added test for psImageTrim.

File:
1 edited

Legend:

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

    r2067 r2074  
    99 *  @author Robert DeSonia, MHPCC
    1010 *
    11  *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-10-13 00:10:50 $
     11 *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-10-13 02:40:13 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    195195    }
    196196
     197    if (col1 < 1) {
     198        col1 += image->numCols;
     199    }
     200
     201    if (row1 < 1) {
     202        row1 += image->numRows;
     203    }
     204
    197205    if (    col0 < 0 ||
    198206            row0 < 0 ||
    199             col1 >= image->numCols ||
    200             row1 >= image->numRows ||
    201             col0 > col1 ||
    202             row0 > row1 ) {
     207            col1 > image->numCols ||
     208            row1 > image->numRows ||
     209            col0 >= col1 ||
     210            row0 >= row1 ) {
    203211        psErrorMsg(PS_ERRORNAME_DOMAIN "psImageTrim",
    204212                   PS_ERR_BAD_PARAMETER_VALUE, true,
    205213                   PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
    206                    col0, col1, row0, row1,
    207                    image->numCols, image->numRows);
     214                   col0, col1-1, row0, row1-1,
     215                   image->numCols-1, image->numRows-1);
     216        psFree(image);
    208217        return NULL;
    209218    }
     
    212221
    213222    unsigned int elementSize = PSELEMTYPE_SIZEOF(image->type.type);
    214     unsigned int numCols = col1-col0+1;
    215     unsigned int numRows = row1-row0+1;
     223    unsigned int numCols = col1-col0;
     224    unsigned int numRows = row1-row0;
    216225    unsigned int rowSize = elementSize*numCols;
    217226    unsigned int colOffset = elementSize * col0;
    218     void* imageData = image->rawDataBuffer;
     227    psU8* imageData = image->rawDataBuffer;
    219228    for (int row = row0; row < row1; row++) {
    220229        memmove(imageData,image->data.U8[row] + colOffset,rowSize);
    221         imageData = (psU8*)imageData + rowSize;
     230        imageData += rowSize;
    222231    }
    223232
     
    265274    }
    266275
    267     if (col1 < 0) {
     276    if (col1 < 1) {
    268277        col1 += in->numCols;
    269278    }
    270279
    271     if (row1 < 0) {
     280    if (row1 < 1) {
    272281        row1 += in->numRows;
    273282    }
     
    275284    if (    col0 < 0 ||
    276285            row0 < 0 ||
    277             col1 >= in->numCols ||
    278             row1 >= in->numRows ||
     286            col1 > in->numCols ||
     287            row1 > in->numRows ||
    279288            col0 >= col1 ||
    280289            row0 >= row1) {
Note: See TracChangeset for help on using the changeset viewer.