IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 13, 2006, 5:25:48 PM (20 years ago)
Author:
drobbin
Message:

Updated psImageGet in accordance with rules for dealing with sub-images.

File:
1 edited

Legend:

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

    r6574 r6578  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.96 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-03-14 02:22:55 $
     11 *  @version $Revision: 1.97 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-03-14 03:25:48 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    319319    PS_ASSERT_INT_NONNEGATIVE(image->col0, false);
    320320    PS_ASSERT_INT_NONNEGATIVE(image->row0, false);
    321     PS_ASSERT_INT_NONNEGATIVE(image->numCols, false);
    322     PS_ASSERT_INT_NONNEGATIVE(image->numRows, false);
     321    PS_ASSERT_INT_POSITIVE(image->numCols, false);
     322    PS_ASSERT_INT_POSITIVE(image->numRows, false);
    323323    if ( x >= (image->col0 + image->numCols) ) {
    324324        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     
    414414                          int y)
    415415{
    416     if (image == NULL) {
    417         psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL);
    418         return NAN;
    419     }
    420     if (x >= image->numRows || y >= image->numCols) {
    421         psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Position too large\n");
    422         return NAN;
    423     }
    424 
    425     if(x < 0)
    426         x += image->numRows;
    427     if(x < 0) {
    428         psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid x.  Negative number too large\n");
    429         return NAN;
    430     }
    431 
    432     if(y < 0)
    433         y += image->numCols;
    434     if(y < 0) {
    435         psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid y.  Negative number too large\n");
    436         return NAN;
    437     }
     416    /*    if (image == NULL) {
     417            psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL);
     418            return NAN;
     419        }
     420        if (x >= image->numRows || y >= image->numCols) {
     421            psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Position too large\n");
     422            return NAN;
     423        }
     424     
     425        if(x < 0)
     426            x += image->numRows;
     427        if(x < 0) {
     428            psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid x.  Negative number too large\n");
     429            return NAN;
     430        }
     431     
     432        if(y < 0)
     433            y += image->numCols;
     434        if(y < 0) {
     435            psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid y.  Negative number too large\n");
     436            return NAN;
     437        }
     438    */
     439    PS_ASSERT_IMAGE_NON_NULL(image, NAN);
     440    PS_ASSERT_INT_NONNEGATIVE(image->col0, NAN);
     441    PS_ASSERT_INT_NONNEGATIVE(image->row0, NAN);
     442    PS_ASSERT_INT_POSITIVE(image->numCols, NAN);
     443    PS_ASSERT_INT_POSITIVE(image->numRows, NAN);
     444    if ( x >= (image->col0 + image->numCols) ) {
     445        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     446                "Invalid x-position %d.  Position out of range (%d-%d)\n",
     447                x, image->col0, image->numCols+image->col0-1 );
     448        return false;
     449    } else if ( y >= (image->row0 + image->numRows) ) {
     450        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     451                "Invalid y-position %d.  Position out of range (%d-%d)\n",
     452                y, image->row0, image->numRows+image->row0-1 );
     453        return false;
     454    } else if (x < image->col0 && x >= 0) {
     455        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     456                "Invalid x-position %d.  Position out of range (%d-%d)\n",
     457                x, image->col0, image->numCols+image->col0-1 );
     458        return false;
     459    } else if (y < image->row0 && y >= 0) {
     460        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     461                "Invalid y-position %d.  Position out of range (%d-%d)\n",
     462                y, image->row0, image->numRows+image->row0-1 );
     463        return false;
     464    } else if (x < 0 || y < 0) {
     465        if (x < 0) {
     466            x += image->numCols;
     467        }
     468        if (x < 0) {
     469            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     470                    "Invalid x-position %d.  Position out of range (%d-%d)\n",
     471                    (x+image->col0), image->col0, image->numCols+image->col0-1 );
     472            return false;
     473        }
     474        if (y < 0) {
     475            y += image->numRows;
     476        }
     477        if (y < 0) {
     478            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     479                    "Invalid y-position %d.  Position out of range (%d-%d)\n",
     480                    (y+image->row0), image->row0, image->numRows+image->row0-1 );
     481            return false;
     482        }
     483    } else {
     484        x -= image->col0;
     485        y -= image->row0;
     486    }
     487
    438488
    439489    switch (image->type.type) {
Note: See TracChangeset for help on using the changeset viewer.