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