Changeset 633 for trunk/psLib/src/image/psImage.c
- Timestamp:
- May 10, 2004, 10:20:42 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/image/psImage.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImage.c
r599 r633 7 7 * @author Ross Harman, MHPCC 8 8 * 9 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-05- 07 02:56:52 $9 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-05-10 20:20:42 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 17 17 /******************************************************************************/ 18 18 #include "psMemory.h" 19 #include "psError.h" 19 20 #include "psArray.h" 21 #include "psImage.h" 20 22 21 23 /******************************************************************************/ … … 53 55 /*****************************************************************************/ 54 56 55 psImage *psImageAlloc(int n x, int ny, psType type)57 psImage *psImageAlloc(int nCols, int nRows, psType type) 56 58 { 57 59 psImage *image = NULL; 58 60 59 psImage = psAlloc(psImage);60 psImage->type = type;61 psImage->nx = nx;62 psImage->ny = ny;63 psImage->x0 = 0;64 psImage->y0 = 0;65 psImage->parent = NULL;66 psImage->nChildren = 0;67 psImage->children = NULL;61 image = psAlloc(sizeof(psImage)); 62 image->type = type; 63 image->nCols = nCols; 64 image->nRows = nRows; 65 image->col0 = 0; 66 image->row0 = 0; 67 image->parent = NULL; 68 image->nChildren = 0; 69 image->children = NULL; 68 70 69 71 switch(type.type) { 70 72 case PS_TYPE_SHORT: 71 image->rows.rows_s i = psAlloc(nx*ny*sizeof(short));73 image->rows.rows_s = psAlloc(nCols*nRows*sizeof(short)); 72 74 break; 73 75 case PS_TYPE_INT: 74 image->rows.rows_i = psAlloc(n x*ny*sizeof(int));76 image->rows.rows_i = psAlloc(nCols*nRows*sizeof(int)); 75 77 break; 76 78 case PS_TYPE_LONG: 77 image->rows.rows_l i = psAlloc(nx*ny*sizeof(long));79 image->rows.rows_l = psAlloc(nCols*nRows*sizeof(long)); 78 80 break; 79 81 case PS_TYPE_USHORT: 80 image->rows.rows_us = psAlloc(n x*ny*sizeof(unsigned short));82 image->rows.rows_us = psAlloc(nCols*nRows*sizeof(unsigned short)); 81 83 break; 82 84 case PS_TYPE_UINT: 83 image->rows.rows_ui = psAlloc(n x*ny*sizeof(unsigned int));85 image->rows.rows_ui = psAlloc(nCols*nRows*sizeof(unsigned int)); 84 86 break; 85 87 case PS_TYPE_ULONG: 86 image->rows.rows_ul = psAlloc(n x*ny*sizeof(unsigned long));88 image->rows.rows_ul = psAlloc(nCols*nRows*sizeof(unsigned long)); 87 89 break; 88 90 case PS_TYPE_FLOAT: 89 image->rows.rows_f = psAlloc(n x*ny*sizeof(float));91 image->rows.rows_f = psAlloc(nCols*nRows*sizeof(float)); 90 92 break; 91 93 case PS_TYPE_DOUBLE: 92 image->rows.rows_d = psAlloc(n x*ny*sizeof(double));94 image->rows.rows_d = psAlloc(nCols*nRows*sizeof(double)); 93 95 break; 94 96 case PS_TYPE_COMPLEX: 95 image->rows.rows_cf = psAlloc(nx*ny*sizeof(complex float)); 96 break; 97 case PS_TYPE_OTHER: 98 psError(__func__, " : Line %d - Invalid psBitMask binary operation: %s\n", __LINE__); 97 image->rows.rows_cf = psAlloc(nCols*nRows*sizeof(complex float)); 99 98 break; 100 99 default: 101 psError(__func__, " : Line %d - Invalid ps BitMask binary operation: %s\n", __LINE__);100 psError(__func__, " : Line %d - Invalid psImage type: %d\n", __LINE__, type.type); 102 101 } 103 102 103 return image; 104 } 104 105 106 void psImageFree(psImage *image) 107 { 108 int i = 0; 109 int nChildren = 0; 110 psElemType imageType = 0; 111 psImage *children = NULL; 112 113 if(image != NULL) { 114 imageType = image->type.type; 115 nChildren = image->nChildren; 116 children = image->children; 117 118 switch(imageType) { 119 case PS_TYPE_SHORT: 120 psFree(image->rows.rows_s); 121 break; 122 case PS_TYPE_INT: 123 psFree(image->rows.rows_i); 124 break; 125 case PS_TYPE_LONG: 126 psFree(image->rows.rows_l); 127 break; 128 case PS_TYPE_USHORT: 129 psFree(image->rows.rows_us); 130 break; 131 case PS_TYPE_UINT: 132 psFree(image->rows.rows_ui); 133 break; 134 case PS_TYPE_ULONG: 135 psFree(image->rows.rows_ul); 136 break; 137 case PS_TYPE_FLOAT: 138 psFree(image->rows.rows_f); 139 break; 140 case PS_TYPE_DOUBLE: 141 psFree(image->rows.rows_d); 142 break; 143 case PS_TYPE_COMPLEX: 144 psFree(image->rows.rows_cf); 145 break; 146 case PS_TYPE_OTHER: 147 psError(__func__, " : Line %d - Can't delete images of type PS_TYPE_OTHER\n", __LINE__); 148 break; 149 default: 150 psError(__func__, " : Line %d - Invalid psImage type: %d\n", __LINE__, imageType); 151 } 152 153 for(i=0; i<nChildren; i++) { 154 psImageFree(children); 155 } 156 } 105 157 }
Note:
See TracChangeset
for help on using the changeset viewer.
