IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 16, 2004, 10:00:21 AM (22 years ago)
Author:
desonia
Message:

Added some psfits and pslist changes. More work needs to be done to make it match the current SDRS.

File:
1 edited

Legend:

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

    r2291 r2375  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-11-06 00:44:56 $
     11 *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-16 20:00:21 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2626#include "psImageErrors.h"
    2727
    28 static void imageFree(psImage* image);
     28static void imageFree(psImage* image)
     29{
     30    if (image == NULL) {
     31        return;
     32    }
     33
     34    if (image->type.type == PS_TYPE_PTR) {
     35        // 2-D array of pointers -- must dereference elements
     36        psU32 oldNumRows = image->numRows;
     37        psU32 oldNumCols = image->numCols;
     38        psPtr* rowPtr;
     39
     40        for (psU32 row = 0; row < oldNumRows; row++) {
     41            rowPtr = image->data.PTR[row];
     42            for (psU32 col = 0; col < oldNumCols; col++) {
     43                psMemDecrRefCounter(rowPtr[col]);
     44            }
     45        }
     46    }
     47
     48    if (image->parent != NULL) {
     49        psArrayRemove(image->parent->children,image);
     50        image->parent = NULL;
     51    }
     52
     53    psImageFreeChildren(image);
     54
     55    psFree(image->rawDataBuffer);
     56    psFree(image->data.V);
     57}
    2958
    3059psImage* psImageAlloc(psU32 numCols,
     
    71100}
    72101
    73 static void imageFree(psImage* image)
     102psRegion* psRegionAlloc(double x0,
     103                        double x1,
     104                        double y0,
     105                        double y1)
    74106{
    75     if (image == NULL) {
    76         return;
    77     }
    78 
    79     if (image->type.type == PS_TYPE_PTR) {
    80         // 2-D array of pointers -- must dereference elements
    81         psU32 oldNumRows = image->numRows;
    82         psU32 oldNumCols = image->numCols;
    83         psPtr* rowPtr;
    84 
    85         for (psU32 row = 0; row < oldNumRows; row++) {
    86             rowPtr = image->data.PTR[row];
    87             for (psU32 col = 0; col < oldNumCols; col++) {
    88                 psMemDecrRefCounter(rowPtr[col]);
    89             }
    90         }
    91     }
    92 
    93     if (image->parent != NULL) {
    94         psArrayRemove(image->parent->children,image);
    95         image->parent = NULL;
    96     }
    97 
    98     psImageFreeChildren(image);
    99 
    100     psFree(image->rawDataBuffer);
    101     psFree(image->data.V);
    102 }
     107    psRegion* out = psAlloc(sizeof(psRegion));
     108
     109    out->x0 = x0;
     110    out->y0 = y0;
     111    out->x1 = x1;
     112    out->y1 = y1;
     113
     114    return out;
     115}
     116
     117
     118
     119psRegion* psRegionFromString(char* region)
     120{
     121    psS32 col0;
     122    psS32 col1;
     123    psS32 row0;
     124    psS32 row1;
     125
     126    // section should be of the form '[col0:col1,row0:row1]'
     127    if (region == NULL) {
     128        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     129                PS_ERRORTEXT_psImage_SUBSECTION_NULL);
     130        return NULL;
     131    }
     132
     133    if (sscanf(region,"[%d:%d,%d:%d]",&col0,&col1,&row0,&row1) < 4) {
     134        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     135                PS_ERRORTEXT_psImage_SUBSECTION_INVALID,
     136                region);
     137        return NULL;
     138    }
     139
     140    if (col0 > col1 || row0 > row1) {
     141        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     142                PS_ERRORTEXT_psImage_SUBSET_RANGE_MALFORMED,
     143                col0,col1,row0,row1);
     144        return NULL;
     145    }
     146
     147    return psRegionAlloc(col0,col1,row0,row1);
     148}
     149
    103150
    104151psImage* psImageRecycle(psImage* old,
Note: See TracChangeset for help on using the changeset viewer.