Changeset 13741 for trunk/psLib/src/math/psRegion.c
- Timestamp:
- Jun 10, 2007, 7:54:05 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psRegion.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psRegion.c
r10999 r13741 8 8 #include "psError.h" 9 9 #include "psAssert.h" 10 #include "psConstants.h" 10 11 #include "psRegion.h" 11 12 … … 83 84 } 84 85 86 psRegion psRegionAndParityFromString(int *xParity, int *yParity, const char* region) 87 { 88 PS_ASSERT_PTR_NON_NULL (xParity, psRegionSet(NAN,NAN,NAN,NAN)); 89 PS_ASSERT_PTR_NON_NULL (yParity, psRegionSet(NAN,NAN,NAN,NAN)); 90 91 psS32 col0; 92 psS32 col1; 93 psS32 row0; 94 psS32 row1; 95 96 // unless otherwise detected 97 *xParity = +1; 98 *yParity = +1; 99 100 // section should be of the form '[col0:col1,row0:row1]' 101 if (region == NULL) { 102 return psRegionSet(0,0,0,0); 103 } 104 105 if (sscanf(region,"[%d:%d,%d:%d]",&col0,&col1,&row0,&row1) < 4) { 106 psError(PS_ERR_BAD_PARAMETER_NULL, true, 107 _("Specified subsection string, '%s', can not be parsed. Must be in the form '[x1:x2,y1:y2]'."), 108 region); 109 return psRegionSet(NAN,NAN,NAN,NAN); 110 } 111 112 // [0:0,0:0] is complete image region 113 if ((col0 == 0) && (col1 == 0) && (row0 == 0) && (row1 == 0)) { 114 return psRegionSet(0,0,0,0); 115 } 116 117 if ((col1 > 0) && (col0 > col1)) { 118 *xParity = -1; 119 PS_SWAP (col0, col1); 120 } 121 122 if ((row1 > 0) && (row0 > row1)) { 123 *yParity = -1; 124 PS_SWAP (row0, row1); 125 } 126 127 return psRegionSet(col0-1,col1,row0-1,row1); 128 } 129 85 130 psString psRegionToString(const psRegion region) 86 131 {
Note:
See TracChangeset
for help on using the changeset viewer.
