Changeset 812
- Timestamp:
- May 28, 2004, 3:09:53 PM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 4 edited
-
image/psImage.c (modified) (7 diffs)
-
image/psImage.h (modified) (3 diffs)
-
mathtypes/psImage.c (modified) (7 diffs)
-
mathtypes/psImage.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImage.c
r791 r812 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-05-2 6 22:55:46$11 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-05-29 01:09:53 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 75 75 } 76 76 77 if (image->type.type == PS_TYPE_PTR) { 78 // 2-D array of pointers -- must dereference 79 unsigned int oldNumRows = image->numRows; 80 unsigned int oldNumCols = image->numCols; 81 psPTR* rowPtr; 82 83 for(unsigned int row=0;row<oldNumRows;row++) { 84 rowPtr = image->data.PTR[row]; 85 for (unsigned int col=0;col<oldNumCols;col++) { 86 psMemDecrRefCounter(rowPtr[col]); 87 } 88 } 89 } 90 77 91 psImageFreeChildren(image); 78 92 … … 84 98 } 85 99 86 psImage* psImageRealloc(psImage* old,unsigned int numCols, unsigned int numRows, 100 psImage* psImageRecycle(psImage* old, 101 unsigned int numCols, 102 unsigned int numRows, 87 103 const psElemType type) 88 104 { … … 96 112 97 113 if (old->type.dimen != PS_DIMEN_IMAGE) { 98 psError(__func__,"Can not realloc image because image is not an image."); 99 return NULL; 114 psError(__func__,"Can not realloc image because input is not an image."); 115 return NULL; 116 } 117 118 if (old->type.type == PS_TYPE_PTR) { 119 // 2-D array of pointers -- must dereference 120 unsigned int oldNumRows = old->numRows; 121 unsigned int oldNumCols = old->numCols; 122 psPTR* rowPtr; 123 124 for(unsigned int row=0;row<oldNumRows;row++) { 125 rowPtr = old->data.PTR[row]; 126 for (unsigned int col=0;col<oldNumCols;col++) { 127 psMemDecrRefCounter(rowPtr[col]); 128 rowPtr[col] = NULL; 129 } 130 } 100 131 } 101 132 … … 163 194 elementSize = PSELEMTYPE_SIZEOF(image->type.type); 164 195 165 out = psImageRe alloc(out,numCols,numRows,image->type.type);196 out = psImageRecycle(out,numCols,numRows,image->type.type); 166 197 167 198 // set the parent information into the child output image … … 245 276 } 246 277 247 output = psImageRe alloc(output,numCols,numRows,type);278 output = psImageRecycle(output,numCols,numRows,type); 248 279 249 280 // cover the trival case of copy of the same datatype. … … 470 501 switch (bitPix) { 471 502 case BYTE_IMG: 472 psImageRe alloc(output,numCols,numRows,PS_TYPE_U8);503 psImageRecycle(output,numCols,numRows,PS_TYPE_U8); 473 504 (void)fits_read_subset(fptr, TBYTE, firstPixel, lastPixel, increment, 474 505 NULL, output->data.v, &anynull, &status); 475 506 break; 476 507 case SHORT_IMG: 477 psImageRe alloc(output,numCols,numRows,PS_TYPE_S16);508 psImageRecycle(output,numCols,numRows,PS_TYPE_S16); 478 509 (void)fits_read_subset(fptr, TSHORT, firstPixel, lastPixel, increment, 479 510 NULL, output->data.v, &anynull, &status); 480 511 break; 481 512 case LONG_IMG: 482 psImageRe alloc(output,numCols,numRows,PS_TYPE_S32);513 psImageRecycle(output,numCols,numRows,PS_TYPE_S32); 483 514 (void)fits_read_subset(fptr, TINT, firstPixel, lastPixel, increment, 484 515 NULL, output->data.v, &anynull, &status); 485 516 break; 486 517 case FLOAT_IMG: 487 psImageRe alloc(output,numCols,numRows,PS_TYPE_F32);518 psImageRecycle(output,numCols,numRows,PS_TYPE_F32); 488 519 (void)fits_read_subset(fptr, TFLOAT, firstPixel, lastPixel, increment, 489 520 NULL, output->data.v, &anynull, &status); 490 521 break; 491 522 case DOUBLE_IMG: 492 psImageRe alloc(output,numCols,numRows,PS_TYPE_F64);523 psImageRecycle(output,numCols,numRows,PS_TYPE_F64); 493 524 (void)fits_read_subset(fptr, TDOUBLE, firstPixel, lastPixel, increment, 494 525 NULL, output->data.v, &anynull, &status); -
trunk/psLib/src/image/psImage.h
r789 r812 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-05-2 6 00:38:34$11 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-05-29 01:09:53 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 58 58 psC32 **C32; ///< single-precision complex data. 59 59 psC64 **C64; ///< double-precision complex data. 60 void **v; ///< void pointers to data 60 psPTR **PTR; ///< void pointers 61 void **v; ///< pointer to data 61 62 } data; ///< Union for data types. 62 63 const struct psImage *parent; ///< Parent, if a subimage. … … 90 91 * 91 92 */ 92 psImage* psImageRe alloc(93 psImage* psImageRecycle( 93 94 psImage* old, ///< the psImage to recycle by resizing image buffer 94 95 unsigned int numCols, ///< the desired number of columns in image -
trunk/psLib/src/mathtypes/psImage.c
r791 r812 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-05-2 6 22:55:46$11 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-05-29 01:09:53 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 75 75 } 76 76 77 if (image->type.type == PS_TYPE_PTR) { 78 // 2-D array of pointers -- must dereference 79 unsigned int oldNumRows = image->numRows; 80 unsigned int oldNumCols = image->numCols; 81 psPTR* rowPtr; 82 83 for(unsigned int row=0;row<oldNumRows;row++) { 84 rowPtr = image->data.PTR[row]; 85 for (unsigned int col=0;col<oldNumCols;col++) { 86 psMemDecrRefCounter(rowPtr[col]); 87 } 88 } 89 } 90 77 91 psImageFreeChildren(image); 78 92 … … 84 98 } 85 99 86 psImage* psImageRealloc(psImage* old,unsigned int numCols, unsigned int numRows, 100 psImage* psImageRecycle(psImage* old, 101 unsigned int numCols, 102 unsigned int numRows, 87 103 const psElemType type) 88 104 { … … 96 112 97 113 if (old->type.dimen != PS_DIMEN_IMAGE) { 98 psError(__func__,"Can not realloc image because image is not an image."); 99 return NULL; 114 psError(__func__,"Can not realloc image because input is not an image."); 115 return NULL; 116 } 117 118 if (old->type.type == PS_TYPE_PTR) { 119 // 2-D array of pointers -- must dereference 120 unsigned int oldNumRows = old->numRows; 121 unsigned int oldNumCols = old->numCols; 122 psPTR* rowPtr; 123 124 for(unsigned int row=0;row<oldNumRows;row++) { 125 rowPtr = old->data.PTR[row]; 126 for (unsigned int col=0;col<oldNumCols;col++) { 127 psMemDecrRefCounter(rowPtr[col]); 128 rowPtr[col] = NULL; 129 } 130 } 100 131 } 101 132 … … 163 194 elementSize = PSELEMTYPE_SIZEOF(image->type.type); 164 195 165 out = psImageRe alloc(out,numCols,numRows,image->type.type);196 out = psImageRecycle(out,numCols,numRows,image->type.type); 166 197 167 198 // set the parent information into the child output image … … 245 276 } 246 277 247 output = psImageRe alloc(output,numCols,numRows,type);278 output = psImageRecycle(output,numCols,numRows,type); 248 279 249 280 // cover the trival case of copy of the same datatype. … … 470 501 switch (bitPix) { 471 502 case BYTE_IMG: 472 psImageRe alloc(output,numCols,numRows,PS_TYPE_U8);503 psImageRecycle(output,numCols,numRows,PS_TYPE_U8); 473 504 (void)fits_read_subset(fptr, TBYTE, firstPixel, lastPixel, increment, 474 505 NULL, output->data.v, &anynull, &status); 475 506 break; 476 507 case SHORT_IMG: 477 psImageRe alloc(output,numCols,numRows,PS_TYPE_S16);508 psImageRecycle(output,numCols,numRows,PS_TYPE_S16); 478 509 (void)fits_read_subset(fptr, TSHORT, firstPixel, lastPixel, increment, 479 510 NULL, output->data.v, &anynull, &status); 480 511 break; 481 512 case LONG_IMG: 482 psImageRe alloc(output,numCols,numRows,PS_TYPE_S32);513 psImageRecycle(output,numCols,numRows,PS_TYPE_S32); 483 514 (void)fits_read_subset(fptr, TINT, firstPixel, lastPixel, increment, 484 515 NULL, output->data.v, &anynull, &status); 485 516 break; 486 517 case FLOAT_IMG: 487 psImageRe alloc(output,numCols,numRows,PS_TYPE_F32);518 psImageRecycle(output,numCols,numRows,PS_TYPE_F32); 488 519 (void)fits_read_subset(fptr, TFLOAT, firstPixel, lastPixel, increment, 489 520 NULL, output->data.v, &anynull, &status); 490 521 break; 491 522 case DOUBLE_IMG: 492 psImageRe alloc(output,numCols,numRows,PS_TYPE_F64);523 psImageRecycle(output,numCols,numRows,PS_TYPE_F64); 493 524 (void)fits_read_subset(fptr, TDOUBLE, firstPixel, lastPixel, increment, 494 525 NULL, output->data.v, &anynull, &status); -
trunk/psLib/src/mathtypes/psImage.h
r789 r812 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-05-2 6 00:38:34$11 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-05-29 01:09:53 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 58 58 psC32 **C32; ///< single-precision complex data. 59 59 psC64 **C64; ///< double-precision complex data. 60 void **v; ///< void pointers to data 60 psPTR **PTR; ///< void pointers 61 void **v; ///< pointer to data 61 62 } data; ///< Union for data types. 62 63 const struct psImage *parent; ///< Parent, if a subimage. … … 90 91 * 91 92 */ 92 psImage* psImageRe alloc(93 psImage* psImageRecycle( 93 94 psImage* old, ///< the psImage to recycle by resizing image buffer 94 95 unsigned int numCols, ///< the desired number of columns in image
Note:
See TracChangeset
for help on using the changeset viewer.
