IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5101 for trunk/psLib/src/types


Ignore:
Timestamp:
Sep 22, 2005, 2:04:36 PM (21 years ago)
Author:
drobbin
Message:

Added and update PixelGet/Set, ImageGet/Set, and test fxns

Location:
trunk/psLib/src/types
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/psPixels.c

    r4898 r5101  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-08-30 01:14:13 $
     9 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-09-23 00:04:36 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    332332    return (true);
    333333}
     334
     335bool psPixelsSet(psPixels *pixels,
     336                 long position,
     337                 psPixelCoord value)
     338{
     339    if (pixels == NULL)
     340        return false;
     341    if (position > pixels->n)
     342        return false;
     343    if(position < 0)
     344        position += pixels->n;
     345    if (position == pixels->n) {
     346        if (position >= pixels->nalloc)
     347            return false;
     348        pixels->n++;
     349    }
     350    pixels->data[position].x = value.x;
     351    pixels->data[position].y = value.y;
     352
     353    return true;
     354}
     355
     356psPixelCoord psPixelsGet(const psPixels *pixels,
     357                         long position)
     358{
     359    psPixelCoord out;
     360    if (pixels == NULL) {
     361        out.x = 0; //XXX: should be NAN when changed to float
     362        out.y = 0; //XXX: should be NAN when changed to float
     363        return out;
     364    }
     365    if (position >= pixels->n) {
     366        out.x = 0; //XXX: should be NAN when changed to float
     367        out.y = 0; //XXX: should be NAN when changed to float
     368        return out;
     369    }
     370    if (position < 0)
     371        position += pixels->n;
     372    out.x = pixels->data[position].x;
     373    out.y = pixels->data[position].y;
     374    return out;
     375}
     376
  • trunk/psLib/src/types/psPixels.h

    r4898 r5101  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-08-30 01:14:13 $
     9 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-09-23 00:04:36 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    161161);
    162162
     163/** Sets the value of the the pixels array at the specified position to value.
     164 *
     165 *  A negative position means index from the end.
     166 *
     167 *  @return bool:       True if Successful, otherwise false.
     168*/
     169bool psPixelsSet(
     170    psPixels *pixels,                  ///< pixels to set
     171    long position,                     ///< position to set
     172    psPixelCoord value                 ///< pixels value to be set
     173);
     174
     175/** Returns the value of the pixels array at the specified position.
     176 *
     177 *  A negative position means index from the end.
     178 *
     179 *  @return psPixelCoord:       The value of the pixels at the specified position.
     180*/
     181psPixelCoord psPixelsGet(
     182    const psPixels *pixels,            ///< input pixels from which to get
     183    long position                      ///< position to get
     184);
     185
    163186#endif // #ifndef PS_PIXELS_H
Note: See TracChangeset for help on using the changeset viewer.