Changeset 3756
- Timestamp:
- Apr 21, 2005, 3:23:15 PM (21 years ago)
- Location:
- branches/bug100/psLib/src/image
- Files:
-
- 2 edited
-
psPixels.c (modified) (8 diffs)
-
psPixels.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/bug100/psLib/src/image/psPixels.c
r3746 r3756 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $10 * @date $Date: 2005-04-22 0 0:06:41 $9 * @version $Revision: 1.3.10.1 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-04-22 01:20:01 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 19 19 #include "psMemory.h" 20 20 21 typedef struct22 {23 psS32 x;24 psS32 y;25 }26 p_psPixelCoord;27 28 21 typedef int(*qsortCompareFcn)(const void *, const void *); 29 22 … … 31 24 { 32 25 if (pixels != NULL) { 33 psFree(pixels->x); 34 psFree(pixels->y); 26 psFree(pixels->data); 35 27 } 36 28 } 37 29 38 30 // for use by qsort, etc. 39 static int comparePixelCoord(p _psPixelCoord* coord1, p_psPixelCoord* coord2)31 static int comparePixelCoord(psPixelCoord* coord1, psPixelCoord* coord2) 40 32 { 41 33 // check row first … … 65 57 66 58 if (size > 0) { 67 out->x = psVectorAlloc(size, PS_TYPE_S32); 68 out->y = psVectorAlloc(size, PS_TYPE_S32); 59 out->data = psAlloc(sizeof(psPixelCoord)*size); 69 60 } else { 70 out->x = NULL; 71 out->y = NULL; 61 out->data = NULL; 72 62 } 73 63 … … 83 73 } 84 74 85 pixels->x = psVectorRealloc(pixels->x, size); 86 pixels->y = psVectorRealloc(pixels->y, size); 75 pixels->data = psRealloc(pixels->data, sizeof(psPixelCoord)*size); 87 76 88 77 return pixels; … … 97 86 return NULL; 98 87 } 99 psVector* xVec = pixels->x; 100 psVector* yVec = pixels->y; 101 if (xVec == NULL || yVec == NULL) { 102 // XXX: Error message 103 psFree(out); 104 return NULL; 105 } 106 if (xVec->type.type != PS_TYPE_S32) { 107 // XXX: Error message 108 psFree(out); 109 return NULL; 110 } 111 if (yVec->type.type != PS_TYPE_S32) { 88 psPixelCoord* data = pixels->data; 89 if (data == NULL) { 112 90 // XXX: Error message 113 91 psFree(out); … … 151 129 152 130 // determine the length of the pixel vector 153 int length = pixels->x->n; 154 if (pixels->y->n != length) { 155 // XXX: warning message 156 if (pixels->y->n < length) { 157 length = pixels->y->n; 158 } 159 } 131 int length = pixels->n; 160 132 161 133 // cycle through the vector of pixels and insert pixels into image 162 134 psMaskType** outData = out->data.PS_TYPE_MASK_DATA; 163 135 for (int p = 0; p < length; p++) { 164 psS32 x = xVec->data.S32[p];165 psS32 y = yVec->data.S32[p];136 psS32 x = data[p].x; 137 psS32 y = data[p].y; 166 138 // pixel in region? 167 139 if (x >= x0 && x < x1 && y >= y0 && y < y1) { … … 198 170 out = psPixelsAlloc(minPixels); 199 171 } 200 psVector* xVec = out->x; 201 psVector* yVec = out->y; 172 psPixelCoord* data = out->data; 202 173 203 174 // check the x and y vector validity (type/minimum size) -
branches/bug100/psLib/src/image/psPixels.h
r3746 r3756 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $10 * @date $Date: 2005-04-22 0 0:06:41$9 * @version $Revision: 1.3.8.1 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-04-22 01:23:15 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 20 20 /// @addtogroup Image 21 21 /// @{ 22 23 typedef struct 24 { 25 psS32 x; 26 psS32 y; 27 } 28 psPixelCoord; 22 29 23 30 /** list of pixel coordinates … … 33 40 typedef struct 34 41 { 35 psVector *x; ///< x coordinate 36 psVector *y; ///< y coordinate 42 int n; 43 int nalloc; 44 psPixelCoord* data; 37 45 } 38 46 psPixels;
Note:
See TracChangeset
for help on using the changeset viewer.
