@@ -113,15 +113,15 @@ bool CxImage::SelectionAddRect(RECT r, BYTE level)
113
113
if (r.left <r.right ) {r2.left =r.left ; r2.right =r.right ; } else {r2.left =r.right ; r2.right =r.left ; }
114
114
if (r.bottom <r.top ) {r2.bottom =r.bottom ; r2.top =r.top ; } else {r2.bottom =r.top ; r2.top =r.bottom ; }
115
115
116
- if (info.rSelectionBox .top <= r2.top ) info.rSelectionBox .top = max (0L ,min (head.biHeight ,r2.top +1 ));
117
- if (info.rSelectionBox .left > r2.left ) info.rSelectionBox .left = max (0L ,min (head.biWidth ,r2.left ));
118
- if (info.rSelectionBox .right <= r2.right ) info.rSelectionBox .right = max (0L ,min (head.biWidth ,r2.right +1 ));
119
- if (info.rSelectionBox .bottom > r2.bottom ) info.rSelectionBox .bottom = max (0L ,min (head.biHeight ,r2.bottom ));
116
+ if (info.rSelectionBox .top <= r2.top ) info.rSelectionBox .top = MAX (0L ,MIN (head.biHeight ,r2.top +1 ));
117
+ if (info.rSelectionBox .left > r2.left ) info.rSelectionBox .left = MAX (0L ,MIN (head.biWidth ,r2.left ));
118
+ if (info.rSelectionBox .right <= r2.right ) info.rSelectionBox .right = MAX (0L ,MIN (head.biWidth ,r2.right +1 ));
119
+ if (info.rSelectionBox .bottom > r2.bottom ) info.rSelectionBox .bottom = MAX (0L ,MIN (head.biHeight ,r2.bottom ));
120
120
121
- long ymin = max (0L ,min (head.biHeight ,r2.bottom ));
122
- long ymax = max (0L ,min (head.biHeight ,r2.top +1 ));
123
- long xmin = max (0L ,min (head.biWidth ,r2.left ));
124
- long xmax = max (0L ,min (head.biWidth ,r2.right +1 ));
121
+ long ymin = MAX (0L ,MIN (head.biHeight ,r2.bottom ));
122
+ long ymax = MAX (0L ,MIN (head.biHeight ,r2.top +1 ));
123
+ long xmin = MAX (0L ,MIN (head.biWidth ,r2.left ));
124
+ long xmax = MAX (0L ,MIN (head.biWidth ,r2.right +1 ));
125
125
126
126
for (long y=ymin; y<ymax; y++)
127
127
memset (pSelection + xmin + y * head.biWidth , level, xmax-xmin);
@@ -144,18 +144,18 @@ bool CxImage::SelectionAddEllipse(RECT r, BYTE level)
144
144
long xcenter = (r.right + r.left )/2 ;
145
145
long ycenter = (r.top + r.bottom )/2 ;
146
146
147
- if (info.rSelectionBox .left > (xcenter - xradius)) info.rSelectionBox .left = max (0L ,min (head.biWidth ,(xcenter - xradius)));
148
- if (info.rSelectionBox .right <= (xcenter + xradius)) info.rSelectionBox .right = max (0L ,min (head.biWidth ,(xcenter + xradius + 1 )));
149
- if (info.rSelectionBox .bottom > (ycenter - yradius)) info.rSelectionBox .bottom = max (0L ,min (head.biHeight ,(ycenter - yradius)));
150
- if (info.rSelectionBox .top <= (ycenter + yradius)) info.rSelectionBox .top = max (0L ,min (head.biHeight ,(ycenter + yradius + 1 )));
147
+ if (info.rSelectionBox .left > (xcenter - xradius)) info.rSelectionBox .left = MAX (0L ,MIN (head.biWidth ,(xcenter - xradius)));
148
+ if (info.rSelectionBox .right <= (xcenter + xradius)) info.rSelectionBox .right = MAX (0L ,MIN (head.biWidth ,(xcenter + xradius + 1 )));
149
+ if (info.rSelectionBox .bottom > (ycenter - yradius)) info.rSelectionBox .bottom = MAX (0L ,MIN (head.biHeight ,(ycenter - yradius)));
150
+ if (info.rSelectionBox .top <= (ycenter + yradius)) info.rSelectionBox .top = MAX (0L ,MIN (head.biHeight ,(ycenter + yradius + 1 )));
151
151
152
- long xmin = max (0L ,min (head.biWidth ,xcenter - xradius));
153
- long xmax = max (0L ,min (head.biWidth ,xcenter + xradius + 1 ));
154
- long ymin = max (0L ,min (head.biHeight ,ycenter - yradius));
155
- long ymax = max (0L ,min (head.biHeight ,ycenter + yradius + 1 ));
152
+ long xmin = MAX (0L ,MIN (head.biWidth ,xcenter - xradius));
153
+ long xmax = MAX (0L ,MIN (head.biWidth ,xcenter + xradius + 1 ));
154
+ long ymin = MAX (0L ,MIN (head.biHeight ,ycenter - yradius));
155
+ long ymax = MAX (0L ,MIN (head.biHeight ,ycenter + yradius + 1 ));
156
156
157
157
long y,yo;
158
- for (y=ymin; y<min (ycenter,ymax); y++){
158
+ for (y=ymin; y<MIN (ycenter,ymax); y++){
159
159
for (long x=xmin; x<xmax; x++){
160
160
yo = (long )(ycenter - yradius * sqrt (1 -pow ((float )(x - xcenter)/(float )xradius,2 )));
161
161
if (yo<y) pSelection[x + y * head.biWidth ] = level;
@@ -268,10 +268,10 @@ bool CxImage::SelectionAddPolygon(POINT *points, long npoints, BYTE level)
268
268
RECT r2;
269
269
if (current->x < next->x ) {r2.left =current->x ; r2.right =next->x ; } else {r2.left =next->x ; r2.right =current->x ; }
270
270
if (current->y < next->y ) {r2.bottom =current->y ; r2.top =next->y ; } else {r2.bottom =next->y ; r2.top =current->y ; }
271
- if (localbox.top < r2.top ) localbox.top = max (0L ,min (head.biHeight -1 ,r2.top +1 ));
272
- if (localbox.left > r2.left ) localbox.left = max (0L ,min (head.biWidth -1 ,r2.left -1 ));
273
- if (localbox.right < r2.right ) localbox.right = max (0L ,min (head.biWidth -1 ,r2.right +1 ));
274
- if (localbox.bottom > r2.bottom ) localbox.bottom = max (0L ,min (head.biHeight -1 ,r2.bottom -1 ));
271
+ if (localbox.top < r2.top ) localbox.top = MAX (0L ,MIN (head.biHeight -1 ,r2.top +1 ));
272
+ if (localbox.left > r2.left ) localbox.left = MAX (0L ,MIN (head.biWidth -1 ,r2.left -1 ));
273
+ if (localbox.right < r2.right ) localbox.right = MAX (0L ,MIN (head.biWidth -1 ,r2.right +1 ));
274
+ if (localbox.bottom > r2.bottom ) localbox.bottom = MAX (0L ,MIN (head.biHeight -1 ,r2.bottom -1 ));
275
275
276
276
i++;
277
277
}
@@ -385,10 +385,10 @@ bool CxImage::SelectionAddPolygon(POINT *points, long npoints, BYTE level)
385
385
for (x=localbox.left ; x<=localbox.right ; x++)
386
386
if (plocal[x + yoffset]!=1 ) pSelection[x + yoffset]=level;
387
387
}
388
- if (info.rSelectionBox .top <= localbox.top ) info.rSelectionBox .top = min (head.biHeight ,localbox.top + 1 );
389
- if (info.rSelectionBox .left > localbox.left ) info.rSelectionBox .left = min (head.biWidth ,localbox.left );
390
- if (info.rSelectionBox .right <= localbox.right ) info.rSelectionBox .right = min (head.biWidth ,localbox.right + 1 );
391
- if (info.rSelectionBox .bottom > localbox.bottom ) info.rSelectionBox .bottom = min (head.biHeight ,localbox.bottom );
388
+ if (info.rSelectionBox .top <= localbox.top ) info.rSelectionBox .top = MIN (head.biHeight ,localbox.top + 1 );
389
+ if (info.rSelectionBox .left > localbox.left ) info.rSelectionBox .left = MIN (head.biWidth ,localbox.left );
390
+ if (info.rSelectionBox .right <= localbox.right ) info.rSelectionBox .right = MIN (head.biWidth ,localbox.right + 1 );
391
+ if (info.rSelectionBox .bottom > localbox.bottom ) info.rSelectionBox .bottom = MIN (head.biHeight ,localbox.bottom );
392
392
393
393
cxfree (plocal);// free(plocal);
394
394
cxfree (pix);// free(pix);
0 commit comments