Changeset 16963
- Timestamp:
- Mar 12, 2008, 3:03:08 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
r16873 r16963 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 39$ $Name: not supported by cvs2svn $10 * @date $Date: 2008-03- 07 22:16:38 $9 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2008-03-13 01:03:08 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 246 246 } 247 247 248 psPixels* psPixelsConcatenate(psPixels *out, 249 const psPixels *pixels) 248 psPixels* psPixelsConcatenate(psPixels *out, const psPixels *pixels) 250 249 { 251 250 PS_ASSERT_PIXELS_NON_NULL(pixels, NULL); 252 253 long pixelsN = pixels->n; // Size of input254 psPixelCoord* pixelsData = pixels->data; // Dereference input255 256 251 if (!out) { 257 // Simply copy pixels 258 out = psPixelsCopy(out, pixels); 259 return out; 260 } 261 262 long outN = out->n; // Size of output 263 psPixelCoord* outData = out->data; // Dereference output 252 return psPixelsCopy(NULL, pixels); 253 } 264 254 265 255 // sort the OUT array to help in searching for duplicates later 266 qsort(outData, outN, sizeof(psPixelCoord), (qsortCompareFunc)comparePixelCoord); 267 268 // add non-duplicate values in pixels to out 269 for (long n = 0; n < pixelsN; n++) { 270 psPixelCoord pCoord = pixelsData[n]; // Coordinate of interest 271 if (!bsearch(&pCoord, outData, outN, sizeof(psPixelCoord), (qsortCompareFunc)comparePixelCoord)) { 272 // no match in OUT array of this value 273 psPixelsAdd(out, 0, pCoord.x, pCoord.y); 256 qsort(out->data, out->n, sizeof(psPixelCoord), (qsortCompareFunc)comparePixelCoord); 257 258 // add non-duplicate values in pixels to the end of the output list (unsorted!) 259 long numInPix = pixels->n; // Number of input pixels 260 long numOutPix = out->n; // (Original) number of output pixels 261 for (long i = 0; i < numInPix; i++) { 262 psPixelCoord pix = pixels->data[i]; // Coordinate of interest 263 if (!bsearch(&pix, out->data, numOutPix, sizeof(psPixelCoord), (qsortCompareFunc)comparePixelCoord)) { 264 psPixelsAdd(out, 0, pix.x, pix.y); 274 265 } 275 266 }
Note:
See TracChangeset
for help on using the changeset viewer.
