Changeset 2375 for trunk/psLib/src/mathtypes
- Timestamp:
- Nov 16, 2004, 10:00:21 AM (22 years ago)
- Location:
- trunk/psLib/src/mathtypes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/mathtypes/psImage.c
r2291 r2375 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.5 3$ $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 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 26 26 #include "psImageErrors.h" 27 27 28 static void imageFree(psImage* image); 28 static 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 } 29 58 30 59 psImage* psImageAlloc(psU32 numCols, … … 71 100 } 72 101 73 static void imageFree(psImage* image) 102 psRegion* psRegionAlloc(double x0, 103 double x1, 104 double y0, 105 double y1) 74 106 { 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 119 psRegion* 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 103 150 104 151 psImage* psImageRecycle(psImage* old, -
trunk/psLib/src/mathtypes/psImage.h
r2204 r2375 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.4 2$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-1 0-27 00:57:31 $13 * @version $Revision: 1.43 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-11-16 20:00:21 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 75 75 psImage; 76 76 77 /** Basic image region structure. 78 * 79 * Struct for specifying a rectangular area in an image. 80 * 81 */ 82 typedef struct 83 { 84 double x0; ///< the first column of the region. 85 double x1; ///< the last column of the region. 86 double y0; ///< the first row of the region. 87 double y1; ///< the last row of the region. 88 } 89 psRegion; 90 77 91 /** Create an image of the specified size and type. 78 92 * … … 84 98 */ 85 99 psImage* psImageAlloc( 86 psU32 numCols, ///< Number of rows in image.87 psU32 numRows, ///< Number of columns in image.100 psU32 numCols, ///< Number of rows in image. 101 psU32 numRows, ///< Number of columns in image. 88 102 const psElemType type ///< Type of data for image. 103 ); 104 105 /** Create an image of the specified size and type. 106 * 107 * Uses psLib memory allocation functions to create an image struct of the 108 * specified size and type. 109 * 110 * @return psImage* : Pointer to psImage. 111 * 112 */ 113 psRegion* psRegionAlloc( 114 double x0, ///< the first column of the region. 115 double x1, ///< the last column of the region. 116 double y0, ///< the first row of the region. 117 double y1 ///< the last row of the region. 118 ); 119 120 psRegion* psRegionFromString( 121 char* region ///< image rectangular region in the form '[x0:x1,y0:y1]' 89 122 ); 90 123 … … 96 129 psImage* psImageRecycle( 97 130 psImage* old, ///< the psImage to recycle by resizing image buffer 98 psU32 numCols, ///< the desired number of columns in image99 psU32 numRows, ///< the desired number of rows in image131 psU32 numCols, ///< the desired number of columns in image 132 psU32 numRows, ///< the desired number of rows in image 100 133 const psElemType type ///< the desired datatype of the image 101 134 );
Note:
See TracChangeset
for help on using the changeset viewer.
