Changeset 13614 for trunk/psLib/test/imageops/tap_psImagePixelManip.c
- Timestamp:
- Jun 4, 2007, 10:25:32 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/imageops/tap_psImagePixelManip.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/imageops/tap_psImagePixelManip.c
r13123 r13614 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 5-02 04:14:33$8 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-06-04 20:25:32 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 18 18 #define VERBOSE false 19 19 20 void genericImageClipTest(int numRows, int numCols) { 21 psMemId id = psMemGetId(); 22 23 psImage *image = psImageAlloc(numCols, numRows, PS_TYPE_F32); 24 for (int row = 0 ; row < numRows ; row++) { 25 for (int col = 0 ; col < numCols ; col++) { 26 image->data.F32[row][col] = (float) (row + col); 27 } 28 } 29 psF32 min = (psF64)numRows/2.0; 30 psF32 max = (psF64)numRows; 31 32 psS32 retVal = psImageClip(image, min, (double)PS_MIN_F32, max, (double)PS_MAX_F32); 33 int numClipped = 0; 34 bool errorFlag = false; 35 for (int row=0;row<numRows;row++) { 36 for (int col=0;col<numCols;col++) { 37 psF32 value = (psF32)(row+col); 38 if (value < min) { 39 numClipped++; 40 value = PS_MIN_F32; 41 } else if (value > max) { 42 numClipped++; 43 value = PS_MAX_F32; 44 } 45 if (fabsf(image->data.F32[row][col]-value) > FLT_EPSILON) { 46 diag("Pixel value is not as expected (%g vs %g) at %u,%u", 47 (psF64)image->data.F32[row][col], (psF64)value, col, row); 48 errorFlag = true; 49 } 50 } 51 } 52 ok(!errorFlag, "psImageClip() produced the correct data values"); 53 ok(retVal == numClipped, "Got the expected number of clips"); 54 psFree(image); 55 56 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 57 } 58 59 20 60 psS32 main(psS32 argc, char* argv[]) 21 61 { 22 62 psLogSetFormat("HLNM"); 23 63 psLogSetLevel(PS_LOG_INFO); 24 plan_tests(1 07);64 plan_tests(122); 25 65 26 66 // test psImageClip() … … 49 89 // and program executions doesn't stop, if input parameter min is larger than max. 50 90 // create image 91 92 genericImageClipTest(8, 1); 93 genericImageClipTest(1, 8); 94 genericImageClipTest(8, 8); 95 genericImageClipTest(8, 16); 96 genericImageClipTest(16, 8); 97 51 98 #define testImageClipByType(datatype) \ 52 99 { \
Note:
See TracChangeset
for help on using the changeset viewer.
