IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 23, 2004, 12:36:04 PM (22 years ago)
Author:
desonia
Message:

changed psImageSubset to subset an image without making a deep copy.

File:
1 edited

Legend:

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

    r1440 r1606  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-08-09 23:34:58 $
     12 *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-08-23 22:36:03 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4343{
    4444    int area = 0;
    45     int elementSize = PSELEMTYPE_SIZEOF(type);  // element
    46 
    47     // size in
    48     // bytes
    49     int rowSize = numCols * elementSize;        // row
    50 
    51     // size
    52 
    53     // in bytes.
     45    int elementSize = PSELEMTYPE_SIZEOF(type);  // element size in bytes
     46    int rowSize = numCols * elementSize;        // row size in bytes.
    5447
    5548    area = numCols * numRows;
     
    7164    image->data.V = psAlloc(sizeof(void *) * numRows);
    7265    if (image->data.V == NULL) {
     66        psFree(image);
    7367        psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
    7468    }
    7569
    76     image->data.V[0] = psAlloc(area * elementSize);
    77     if (image->data.V[0] == NULL) {
     70    image->rawDataBuffer = psAlloc(area * elementSize);
     71    if (image->rawDataBuffer == NULL) {
     72        psFree(image);
     73        psFree(image->data.V);
    7874        psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
    7975    }
    8076
     77    // set the row pointers.
     78    image->data.V[0] = image->rawDataBuffer;
    8179    for (int i = 1; i < numRows; i++) {
    8280        image->data.V[i] = (void *)((int8_t *) image->data.V[i - 1] + rowSize);
     
    119117    psImageFreeChildren(image);
    120118
    121     psFree(image->data.V[0]);
     119    psFree(image->rawDataBuffer);
    122120    psFree(image->data.V);
    123121    image->data.V = NULL;
     
    167165    }
    168166    // Resize the image buffer
    169     old->data.V[0] = psRealloc(old->data.V[0], numCols * numRows * elementSize);
     167    old->rawDataBuffer = psRealloc(old->data.V[0], numCols * numRows * elementSize);
    170168    old->data.V = (void **)psRealloc(old->data.V, numRows * sizeof(void *));
    171169
    172170    // recreate the row pointers
     171    old->data.V[0] = old->rawDataBuffer;
    173172    for (int i = 1; i < numRows; i++) {
    174173        old->data.V[i] = (void *)((int8_t *) old->data.V[i - 1] + rowSize);
Note: See TracChangeset for help on using the changeset viewer.