Changeset 16873
- Timestamp:
- Mar 7, 2008, 12:16:38 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/types/psPixels.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/types/psPixels.c
r16679 r16873 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.3 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2008-0 2-27 02:18:14$9 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2008-03-07 22:16:38 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 251 251 PS_ASSERT_PIXELS_NON_NULL(pixels, NULL); 252 252 253 long pixelsN = pixels->n; 254 psPixelCoord* pixelsData = pixels->data; 255 256 if ( out == NULL) {257 // simplecopy pixels258 out = psPixelsCopy(out, pixels);253 long pixelsN = pixels->n; // Size of input 254 psPixelCoord* pixelsData = pixels->data; // Dereference input 255 256 if (!out) { 257 // Simply copy pixels 258 out = psPixelsCopy(out, pixels); 259 259 return out; 260 260 } 261 261 262 // make sure the out is large enough to fit the result 263 long outN = out->n; 264 out = psPixelsRealloc(out,outN + pixelsN); 265 psPixelCoord* outData = out->data; 262 long outN = out->n; // Size of output 263 psPixelCoord* outData = out->data; // Dereference output 266 264 267 265 // sort the OUT array to help in searching for duplicates later 268 qsort(outData, outN, sizeof(psPixelCoord), 269 (qsortCompareFunc)comparePixelCoord); 266 qsort(outData, outN, sizeof(psPixelCoord), (qsortCompareFunc)comparePixelCoord); 270 267 271 268 // add non-duplicate values in pixels to out 272 psPixelCoord pCoord;273 long end = outN;274 269 for (long n = 0; n < pixelsN; n++) { 275 pCoord = pixelsData[n]; 276 if (bsearch(&pCoord, outData, outN, sizeof(psPixelCoord), 277 (qsortCompareFunc)comparePixelCoord) == NULL) { 270 psPixelCoord pCoord = pixelsData[n]; // Coordinate of interest 271 if (!bsearch(&pCoord, outData, outN, sizeof(psPixelCoord), (qsortCompareFunc)comparePixelCoord)) { 278 272 // no match in OUT array of this value 279 outData[end++] = pCoord;273 psPixelsAdd(out, 0, pCoord.x, pCoord.y); 280 274 } 281 275 } 282 out->n = end; // set number of elements to reflect added data283 276 284 277 return out;
Note:
See TracChangeset
for help on using the changeset viewer.
