@@ -113,15 +113,15 @@ bool CxImage::SelectionAddRect(RECT r, BYTE level)
113113 if (r.left <r.right ) {r2.left =r.left ; r2.right =r.right ; } else {r2.left =r.right ; r2.right =r.left ; }
114114 if (r.bottom <r.top ) {r2.bottom =r.bottom ; r2.top =r.top ; } else {r2.bottom =r.top ; r2.top =r.bottom ; }
115115
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 ));
120120
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 ));
125125
126126 for (long y=ymin; y<ymax; y++)
127127 memset (pSelection + xmin + y * head.biWidth , level, xmax-xmin);
@@ -144,18 +144,18 @@ bool CxImage::SelectionAddEllipse(RECT r, BYTE level)
144144 long xcenter = (r.right + r.left )/2 ;
145145 long ycenter = (r.top + r.bottom )/2 ;
146146
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 )));
151151
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 ));
156156
157157 long y,yo;
158- for (y=ymin; y<min (ycenter,ymax); y++){
158+ for (y=ymin; y<MIN (ycenter,ymax); y++){
159159 for (long x=xmin; x<xmax; x++){
160160 yo = (long )(ycenter - yradius * sqrt (1 -pow ((float )(x - xcenter)/(float )xradius,2 )));
161161 if (yo<y) pSelection[x + y * head.biWidth ] = level;
@@ -268,10 +268,10 @@ bool CxImage::SelectionAddPolygon(POINT *points, long npoints, BYTE level)
268268 RECT r2;
269269 if (current->x < next->x ) {r2.left =current->x ; r2.right =next->x ; } else {r2.left =next->x ; r2.right =current->x ; }
270270 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 ));
275275
276276 i++;
277277 }
@@ -385,10 +385,10 @@ bool CxImage::SelectionAddPolygon(POINT *points, long npoints, BYTE level)
385385 for (x=localbox.left ; x<=localbox.right ; x++)
386386 if (plocal[x + yoffset]!=1 ) pSelection[x + yoffset]=level;
387387 }
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 );
392392
393393 cxfree (plocal);// free(plocal);
394394 cxfree (pix);// free(pix);
0 commit comments