]> Creatis software - clitk.git/commitdiff
COMP: renamed min max macros which are no longer allowed
authorSimon Rit <simon.rit@creatis.insa-lyon.fr>
Tue, 2 Jan 2018 15:11:52 +0000 (16:11 +0100)
committerSimon Rit <simon.rit@creatis.insa-lyon.fr>
Tue, 2 Jan 2018 15:11:52 +0000 (16:11 +0100)
Problem showed up on mac os:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__undef_min_max:29:2:
warning: : macro max is incompatible with C++.  #undefing max

utilities/CxImage/ximadef.h
utilities/CxImage/ximage.cpp
utilities/CxImage/ximagif.cpp
utilities/CxImage/ximaint.cpp
utilities/CxImage/ximaiter.h
utilities/CxImage/ximapal.cpp
utilities/CxImage/ximasel.cpp
utilities/CxImage/ximath.cpp
utilities/CxImage/ximatran.cpp

index b388b2b81f4c8cad255c990374545c446305aea4..e4bf05e9a720d2bf1a1f4a818e8f24b03f977e94 100644 (file)
  #define CXIMAGE_SUPPORT_WINDOWS 0
 #endif
 
-#ifndef min
-#define min(a,b) (((a)<(b))?(a):(b))
+#ifndef __min
+#define __min(a,b) (((a)<(b))?(a):(b))
 #endif
-#ifndef max
-#define max(a,b) (((a)>(b))?(a):(b))
+#ifndef __max
+#define __max(a,b) (((a)>(b))?(a):(b))
 #endif
 
 #ifndef PI
index e81d3c6c8e2487d85c9a310c10aec0dfc2927339..1b94d3b6e13586abcf688402e6f24f31c3e7b230 100644 (file)
@@ -460,7 +460,7 @@ bool CxImage::CreateFromArray(BYTE* pArray,DWORD dwWidth,DWORD dwHeight,DWORD dw
                                src+=4;
                        }
                } else {
-                       memcpy(dst,src,min(info.dwEffWidth,dwBytesperline));
+                       memcpy(dst,src,__min(info.dwEffWidth,dwBytesperline));
                }
        }
        return true;
@@ -500,7 +500,7 @@ bool CxImage::CreateFromMatrix(BYTE** ppMatrix,DWORD dwWidth,DWORD dwHeight,DWOR
                                        src+=4;
                                }
                        } else {
-                               memcpy(dst,src,min(info.dwEffWidth,dwBytesperline));
+                               memcpy(dst,src,__min(info.dwEffWidth,dwBytesperline));
                        }
                }
        }
index 0c89759749f6d88f9a7eda18b989a76fcbf69d7c..16fd3a51b718cd7c3e51edf91411a1ae91c17477 100644 (file)
@@ -478,7 +478,7 @@ bool CxImageGIF::Encode(CxFile * fp, CxImage ** pImages, int pagecount, bool bLo
        ghost.EncodeHeader(fp);
 
        if (m_loops!=1){
-               ghost.SetLoops(max(0,m_loops-1));
+               ghost.SetLoops(__max(0,m_loops-1));
                ghost.EncodeLoopExtension(fp);
        }
 
@@ -1340,10 +1340,10 @@ void CxImageGIF::GetComment(char* sz_comment_out)
 ////////////////////////////////////////////////////////////////////////////////
 void CxImageGIF::GifMix(CxImage & imgsrc2, struct_image & imgdesc)
 {
-       long ymin = max(0,(long)(GetHeight()-imgdesc.t - imgdesc.h));
+       long ymin = __max(0,(long)(GetHeight()-imgdesc.t - imgdesc.h));
        long ymax = GetHeight()-imgdesc.t;
        long xmin = imgdesc.l;
-       long xmax = min(GetWidth(), (DWORD)(imgdesc.l + imgdesc.w));
+       long xmax = __min(GetWidth(), (DWORD)(imgdesc.l + imgdesc.w));
 
        long ibg2= imgsrc2.GetTransIndex();
     BYTE i2;
index c30e882a47e32a34af80d9f5c56d5709128a835c..96b445aa0bd87351cf5ff10daa425a6061b1fc02 100644 (file)
@@ -26,8 +26,8 @@ void CxImage::OverflowCoordinates(long &x, long &y, OverflowMethod const ofMetho
   switch (ofMethod) {
     case OM_REPEAT:
       //clip coordinates
-      x=max(x,0); x=min(x, head.biWidth-1);
-      y=max(y,0); y=min(y, head.biHeight-1);
+      x=__max(x,0); x=__min(x, head.biWidth-1);
+      y=__max(y,0); y=__min(y, head.biHeight-1);
       break;
     case OM_WRAP:
       //wrap coordinates
@@ -59,8 +59,8 @@ void CxImage::OverflowCoordinates(float &x, float &y, OverflowMethod const ofMet
   switch (ofMethod) {
     case OM_REPEAT:
       //clip coordinates
-      x=max(x,0); x=min(x, head.biWidth-1);
-      y=max(y,0); y=min(y, head.biHeight-1);
+      x=__max(x,0); x=__min(x, head.biWidth-1);
+      y=__max(y,0); y=__min(y, head.biHeight-1);
       break;
     case OM_WRAP:
       //wrap coordinates
index 9788919b8f6d63ee9247fd7f1686ea250e1ca82e..cd5c26667c5944998bbb1e1d3591ff3d5ac1f131 100644 (file)
@@ -140,7 +140,7 @@ inline void CImageIterator::SetY(int y)
 inline void CImageIterator::SetRow(BYTE *buf, int n)
 {
        if (n<0) n = (int)ima->GetEffWidth();
-       else n = min(n,(int)ima->GetEffWidth());
+       else n = __min(n,(int)ima->GetEffWidth());
 
        if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0)) memcpy(IterImage,buf,n);
 }
@@ -148,7 +148,7 @@ inline void CImageIterator::SetRow(BYTE *buf, int n)
 inline void CImageIterator::GetRow(BYTE *buf, int n)
 {
        if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0))
-               memcpy(buf,IterImage,min(n,(int)ima->GetEffWidth()));
+               memcpy(buf,IterImage,__min(n,(int)ima->GetEffWidth()));
 }
 /////////////////////////////////////////////////////////////////////
 inline BYTE* CImageIterator::GetRow()
index b3bd3da39a5b7b0c50043d9725246328b2103aba..192776c4acc2d98e4bb5aa1c1fca9cb5caffd7c4 100644 (file)
@@ -398,8 +398,8 @@ void CxImage::RGBtoBGR(BYTE *buffer, int length)
 {
        if (buffer && (head.biClrUsed==0)){
                BYTE temp;
-               length = min(length,(int)info.dwEffWidth);
-               length = min(length,(int)(3*head.biWidth));
+               length = __min(length,(int)info.dwEffWidth);
+               length = __min(length,(int)(3*head.biWidth));
                for (int i=0;i<length;i+=3){
                        temp = buffer[i]; buffer[i] = buffer[i+2]; buffer[i+2] = temp;
                }
@@ -444,7 +444,7 @@ void CxImage::SetPalette(DWORD n, BYTE *r, BYTE *g, BYTE *b)
        if (!g) g = r;
        if (!b) b = g;
        RGBQUAD* ppal=GetPalette();
-       DWORD m=min(n,head.biClrUsed);
+       DWORD m=__min(n,head.biClrUsed);
        for (DWORD i=0; i<m;i++){
                ppal[i].rgbRed=r[i];
                ppal[i].rgbGreen=g[i];
@@ -457,7 +457,7 @@ void CxImage::SetPalette(rgb_color *rgb,DWORD nColors)
 {
        if ((!rgb)||(pDib==NULL)||(head.biClrUsed==0)) return;
        RGBQUAD* ppal=GetPalette();
-       DWORD m=min(nColors,head.biClrUsed);
+       DWORD m=__min(nColors,head.biClrUsed);
        for (DWORD i=0; i<m;i++){
                ppal[i].rgbRed=rgb[i].r;
                ppal[i].rgbGreen=rgb[i].g;
@@ -469,7 +469,7 @@ void CxImage::SetPalette(rgb_color *rgb,DWORD nColors)
 void CxImage::SetPalette(RGBQUAD* pPal,DWORD nColors)
 {
        if ((pPal==NULL)||(pDib==NULL)||(head.biClrUsed==0)) return;
-       memcpy(GetPalette(),pPal,min(GetPaletteSize(),nColors*sizeof(RGBQUAD)));
+       memcpy(GetPalette(),pPal,__min(GetPaletteSize(),nColors*sizeof(RGBQUAD)));
        info.last_c_isvalid = false;
 }
 ////////////////////////////////////////////////////////////////////////////////
@@ -654,10 +654,10 @@ void CxImage::SetClrImportant(DWORD ncolors)
 
        switch(head.biBitCount){
        case 1:
-               head.biClrImportant = min(ncolors,2);
+               head.biClrImportant = __min(ncolors,2);
                break;
        case 4:
-               head.biClrImportant = min(ncolors,16);
+               head.biClrImportant = __min(ncolors,16);
                break;
        case 8:
                head.biClrImportant = ncolors;
index 3a7c9a1845be59b8e90f7a23c651ad48e5134060..669b793e8604180013c658bfdd6b721ce9096199 100644 (file)
@@ -113,15 +113,15 @@ bool CxImage::SelectionAddRect(RECT r, BYTE level)
        if (r.left<r.right) {r2.left=r.left; r2.right=r.right; } else {r2.left=r.right ; r2.right=r.left; }
        if (r.bottom<r.top) {r2.bottom=r.bottom; r2.top=r.top; } else {r2.bottom=r.top ; r2.top=r.bottom; }
 
-       if (info.rSelectionBox.top <= r2.top) info.rSelectionBox.top = max(0L,min(head.biHeight,r2.top+1));
-       if (info.rSelectionBox.left > r2.left) info.rSelectionBox.left = max(0L,min(head.biWidth,r2.left));
-       if (info.rSelectionBox.right <= r2.right) info.rSelectionBox.right = max(0L,min(head.biWidth,r2.right+1));
-       if (info.rSelectionBox.bottom > r2.bottom) info.rSelectionBox.bottom = max(0L,min(head.biHeight,r2.bottom));
+       if (info.rSelectionBox.top <= r2.top) info.rSelectionBox.top = __max(0L,__min(head.biHeight,r2.top+1));
+       if (info.rSelectionBox.left > r2.left) info.rSelectionBox.left = __max(0L,__min(head.biWidth,r2.left));
+       if (info.rSelectionBox.right <= r2.right) info.rSelectionBox.right = __max(0L,__min(head.biWidth,r2.right+1));
+       if (info.rSelectionBox.bottom > r2.bottom) info.rSelectionBox.bottom = __max(0L,__min(head.biHeight,r2.bottom));
 
-       long ymin = max(0L,min(head.biHeight,r2.bottom));
-       long ymax = max(0L,min(head.biHeight,r2.top+1));
-       long xmin = max(0L,min(head.biWidth,r2.left));
-       long xmax = max(0L,min(head.biWidth,r2.right+1));
+       long ymin = __max(0L,__min(head.biHeight,r2.bottom));
+       long ymax = __max(0L,__min(head.biHeight,r2.top+1));
+       long xmin = __max(0L,__min(head.biWidth,r2.left));
+       long xmax = __max(0L,__min(head.biWidth,r2.right+1));
 
        for (long y=ymin; y<ymax; y++)
                memset(pSelection + xmin + y * head.biWidth, level, xmax-xmin);
@@ -144,18 +144,18 @@ bool CxImage::SelectionAddEllipse(RECT r, BYTE level)
        long xcenter = (r.right + r.left)/2;
        long ycenter = (r.top + r.bottom)/2;
 
-       if (info.rSelectionBox.left > (xcenter - xradius)) info.rSelectionBox.left = max(0L,min(head.biWidth,(xcenter - xradius)));
-       if (info.rSelectionBox.right <= (xcenter + xradius)) info.rSelectionBox.right = max(0L,min(head.biWidth,(xcenter + xradius + 1)));
-       if (info.rSelectionBox.bottom > (ycenter - yradius)) info.rSelectionBox.bottom = max(0L,min(head.biHeight,(ycenter - yradius)));
-       if (info.rSelectionBox.top <= (ycenter + yradius)) info.rSelectionBox.top = max(0L,min(head.biHeight,(ycenter + yradius + 1)));
+       if (info.rSelectionBox.left > (xcenter - xradius)) info.rSelectionBox.left = __max(0L,__min(head.biWidth,(xcenter - xradius)));
+       if (info.rSelectionBox.right <= (xcenter + xradius)) info.rSelectionBox.right = __max(0L,__min(head.biWidth,(xcenter + xradius + 1)));
+       if (info.rSelectionBox.bottom > (ycenter - yradius)) info.rSelectionBox.bottom = __max(0L,__min(head.biHeight,(ycenter - yradius)));
+       if (info.rSelectionBox.top <= (ycenter + yradius)) info.rSelectionBox.top = __max(0L,__min(head.biHeight,(ycenter + yradius + 1)));
 
-       long xmin = max(0L,min(head.biWidth,xcenter - xradius));
-       long xmax = max(0L,min(head.biWidth,xcenter + xradius + 1));
-       long ymin = max(0L,min(head.biHeight,ycenter - yradius));
-       long ymax = max(0L,min(head.biHeight,ycenter + yradius + 1));
+       long xmin = __max(0L,__min(head.biWidth,xcenter - xradius));
+       long xmax = __max(0L,__min(head.biWidth,xcenter + xradius + 1));
+       long ymin = __max(0L,__min(head.biHeight,ycenter - yradius));
+       long ymax = __max(0L,__min(head.biHeight,ycenter + yradius + 1));
 
        long y,yo;
-       for (y=ymin; y<min(ycenter,ymax); y++){
+       for (y=ymin; y<__min(ycenter,ymax); y++){
                for (long x=xmin; x<xmax; x++){
                        yo = (long)(ycenter - yradius * sqrt(1-pow((float)(x - xcenter)/(float)xradius,2)));
                        if (yo<y) pSelection[x + y * head.biWidth] = level;
@@ -268,10 +268,10 @@ bool CxImage::SelectionAddPolygon(POINT *points, long npoints, BYTE level)
                RECT r2;
                if (current->x < next->x) {r2.left=current->x; r2.right=next->x; } else {r2.left=next->x ; r2.right=current->x; }
                if (current->y < next->y) {r2.bottom=current->y; r2.top=next->y; } else {r2.bottom=next->y ; r2.top=current->y; }
-               if (localbox.top < r2.top) localbox.top = max(0L,min(head.biHeight-1,r2.top+1));
-               if (localbox.left > r2.left) localbox.left = max(0L,min(head.biWidth-1,r2.left-1));
-               if (localbox.right < r2.right) localbox.right = max(0L,min(head.biWidth-1,r2.right+1));
-               if (localbox.bottom > r2.bottom) localbox.bottom = max(0L,min(head.biHeight-1,r2.bottom-1));
+               if (localbox.top < r2.top) localbox.top = __max(0L,__min(head.biHeight-1,r2.top+1));
+               if (localbox.left > r2.left) localbox.left = __max(0L,__min(head.biWidth-1,r2.left-1));
+               if (localbox.right < r2.right) localbox.right = __max(0L,__min(head.biWidth-1,r2.right+1));
+               if (localbox.bottom > r2.bottom) localbox.bottom = __max(0L,__min(head.biHeight-1,r2.bottom-1));
 
                i++;
        }
@@ -385,10 +385,10 @@ bool CxImage::SelectionAddPolygon(POINT *points, long npoints, BYTE level)
                for (x=localbox.left; x<=localbox.right; x++)
                        if (plocal[x + yoffset]!=1) pSelection[x + yoffset]=level;
        }
-       if (info.rSelectionBox.top <= localbox.top) info.rSelectionBox.top = min(head.biHeight,localbox.top + 1);
-       if (info.rSelectionBox.left > localbox.left) info.rSelectionBox.left = min(head.biWidth,localbox.left);
-       if (info.rSelectionBox.right <= localbox.right) info.rSelectionBox.right = min(head.biWidth,localbox.right + 1);
-       if (info.rSelectionBox.bottom > localbox.bottom) info.rSelectionBox.bottom = min(head.biHeight,localbox.bottom);
+       if (info.rSelectionBox.top <= localbox.top) info.rSelectionBox.top = __min(head.biHeight,localbox.top + 1);
+       if (info.rSelectionBox.left > localbox.left) info.rSelectionBox.left = __min(head.biWidth,localbox.left);
+       if (info.rSelectionBox.right <= localbox.right) info.rSelectionBox.right = __min(head.biWidth,localbox.right + 1);
+       if (info.rSelectionBox.bottom > localbox.bottom) info.rSelectionBox.bottom = __min(head.biHeight,localbox.bottom);
 
        free(plocal);
        free(pix);
index 37533e2280c0e6c0f4227d4a9ee467e0179b6ee2..8d8cf13d0da839ed8498cc2eaaefd7fbc0335546 100644 (file)
@@ -64,10 +64,10 @@ CxRect2 CxRect2::CrossSection(CxRect2 const &r2) const
  */
 {
   CxRect2 cs;
-  cs.botLeft.x=max(botLeft.x, r2.botLeft.x);
-  cs.botLeft.y=max(botLeft.y, r2.botLeft.y);
-  cs.topRight.x=min(topRight.x, r2.topRight.x);
-  cs.topRight.y=min(topRight.y, r2.topRight.y);
+  cs.botLeft.x=__max(botLeft.x, r2.botLeft.x);
+  cs.botLeft.y=__max(botLeft.y, r2.botLeft.y);
+  cs.topRight.x=__min(topRight.x, r2.topRight.x);
+  cs.topRight.y=__min(topRight.y, r2.topRight.y);
   if (cs.botLeft.x<=cs.topRight.x && cs.botLeft.y<=cs.topRight.y) {
     return cs;
   } else {
index d3aac0182ae0e0532080d1c4c72e4abcf7c110e7..dd635cf1185368b1a81311688bd02b540c21916f 100644 (file)
@@ -282,12 +282,12 @@ bool CxImage::RotateLeft(CxImage* iDst)
                        for (ys = 0; ys < newHeight; ys+=RBLOCK) {
                                if (head.biBitCount==24) {
                                        //RGB24 optimized pixel access:
-                                       for (x = xs; x < min(newWidth, xs+RBLOCK); x++){    //do rotation
+                                       for (x = xs; x < __min(newWidth, xs+RBLOCK); x++){    //do rotation
                                                info.nProgress = (long)(100*x/newWidth);
                                                x2=newWidth-x-1;
                                                dstPtr = (BYTE*) imgDest.BlindGetPixelPointer(x,ys);
                                                srcPtr = (BYTE*) BlindGetPixelPointer(ys, x2);
-                                               for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
+                                               for (y = ys; y < __min(newHeight, ys+RBLOCK); y++){
                                                        //imgDest.SetPixelColor(x, y, GetPixelColor(y, x2));
                                                        *(dstPtr) = *(srcPtr);
                                                        *(dstPtr+1) = *(srcPtr+1);
@@ -298,19 +298,19 @@ bool CxImage::RotateLeft(CxImage* iDst)
                                        }//for x
                                } else {
                                        //anything else than 24bpp (and 1bpp): palette
-                                       for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
+                                       for (x = xs; x < __min(newWidth, xs+RBLOCK); x++){
                                                info.nProgress = (long)(100*x/newWidth); //<Anatoly Ivasyuk>
                                                x2=newWidth-x-1;
-                                               for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
+                                               for (y = ys; y < __min(newHeight, ys+RBLOCK); y++){
                                                        imgDest.SetPixelIndex(x, y, BlindGetPixelIndex(y, x2));
                                                }//for y
                                        }//for x
                                }//if (version selection)
 #if CXIMAGE_SUPPORT_ALPHA
                                if (AlphaIsValid()) {
-                                       for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
+                                       for (x = xs; x < __min(newWidth, xs+RBLOCK); x++){
                                                x2=newWidth-x-1;
-                                               for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
+                                               for (y = ys; y < __min(newHeight, ys+RBLOCK); y++){
                                                        imgDest.AlphaSet(x,y,BlindAlphaGet(y, x2));
                                                }//for y
                                        }//for x
@@ -323,9 +323,9 @@ bool CxImage::RotateLeft(CxImage* iDst)
                                        imgDest.info.rSelectionBox.right = newWidth-info.rSelectionBox.bottom;
                                        imgDest.info.rSelectionBox.bottom = info.rSelectionBox.left;
                                        imgDest.info.rSelectionBox.top = info.rSelectionBox.right;
-                                       for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
+                                       for (x = xs; x < __min(newWidth, xs+RBLOCK); x++){
                                                x2=newWidth-x-1;
-                                               for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
+                                               for (y = ys; y < __min(newHeight, ys+RBLOCK); y++){
                                                        imgDest.SelectionSet(x,y,BlindSelectionGet(y, x2));
                                                }//for y
                                        }//for x
@@ -427,12 +427,12 @@ bool CxImage::RotateRight(CxImage* iDst)
                        for (ys = 0; ys < newHeight; ys+=RBLOCK) {
                                if (head.biBitCount==24) {
                                        //RGB24 optimized pixel access:
-                                       for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
+                                       for (y = ys; y < __min(newHeight, ys+RBLOCK); y++){
                                                info.nProgress = (long)(100*y/newHeight); //<Anatoly Ivasyuk>
                                                y2=newHeight-y-1;
                                                dstPtr = (BYTE*) imgDest.BlindGetPixelPointer(xs,y);
                                                srcPtr = (BYTE*) BlindGetPixelPointer(y2, xs);
-                                               for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
+                                               for (x = xs; x < __min(newWidth, xs+RBLOCK); x++){
                                                        //imgDest.SetPixelColor(x, y, GetPixelColor(y2, x));
                                                        *(dstPtr) = *(srcPtr);
                                                        *(dstPtr+1) = *(srcPtr+1);
@@ -443,19 +443,19 @@ bool CxImage::RotateRight(CxImage* iDst)
                                        }//for y
                                } else {
                                        //anything else than BW & RGB24: palette
-                                       for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
+                                       for (y = ys; y < __min(newHeight, ys+RBLOCK); y++){
                                                info.nProgress = (long)(100*y/newHeight); //<Anatoly Ivasyuk>
                                                y2=newHeight-y-1;
-                                               for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
+                                               for (x = xs; x < __min(newWidth, xs+RBLOCK); x++){
                                                        imgDest.SetPixelIndex(x, y, BlindGetPixelIndex(y2, x));
                                                }//for x
                                        }//for y
                                }//if
 #if CXIMAGE_SUPPORT_ALPHA
                                if (AlphaIsValid()){
-                                       for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
+                                       for (y = ys; y < __min(newHeight, ys+RBLOCK); y++){
                                                y2=newHeight-y-1;
-                                               for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
+                                               for (x = xs; x < __min(newWidth, xs+RBLOCK); x++){
                                                        imgDest.AlphaSet(x,y,BlindAlphaGet(y2, x));
                                                }//for x
                                        }//for y
@@ -468,9 +468,9 @@ bool CxImage::RotateRight(CxImage* iDst)
                                        imgDest.info.rSelectionBox.right = info.rSelectionBox.top;
                                        imgDest.info.rSelectionBox.bottom = newHeight-info.rSelectionBox.right;
                                        imgDest.info.rSelectionBox.top = newHeight-info.rSelectionBox.left;
-                                       for (y = ys; y < min(newHeight, ys+RBLOCK); y++){
+                                       for (y = ys; y < __min(newHeight, ys+RBLOCK); y++){
                                                y2=newHeight-y-1;
-                                               for (x = xs; x < min(newWidth, xs+RBLOCK); x++){
+                                               for (x = xs; x < __min(newWidth, xs+RBLOCK); x++){
                                                        imgDest.SelectionSet(x,y,BlindSelectionGet(y2, x));
                                                }//for x
                                        }//for y
@@ -588,10 +588,10 @@ bool CxImage::Rotate(float angle, CxImage* iDst)
        newP4.x = (float)(p4.x*cos_angle - p4.y*sin_angle);
        newP4.y = (float)(p4.x*sin_angle + p4.y*cos_angle);
 
-       leftTop.x = min(min(newP1.x,newP2.x),min(newP3.x,newP4.x));
-       leftTop.y = min(min(newP1.y,newP2.y),min(newP3.y,newP4.y));
-       rightBottom.x = max(max(newP1.x,newP2.x),max(newP3.x,newP4.x));
-       rightBottom.y = max(max(newP1.y,newP2.y),max(newP3.y,newP4.y));
+       leftTop.x = __min(__min(newP1.x,newP2.x),__min(newP3.x,newP4.x));
+       leftTop.y = __min(__min(newP1.y,newP2.y),__min(newP3.y,newP4.y));
+       rightBottom.x = __max(__max(newP1.x,newP2.x),__max(newP3.x,newP4.x));
+       rightBottom.y = __max(__max(newP1.y,newP2.y),__max(newP3.y,newP4.y));
        leftBottom.x = leftTop.x;
        leftBottom.y = rightBottom.y;
        rightTop.x = rightBottom.x;
@@ -720,10 +720,10 @@ bool CxImage::Rotate2(float angle,
        }//if
 
        //(read new dimensions from location of corners)
-       float minx = (float) min(min(newp[0].x,newp[1].x),min(newp[2].x,newp[3].x));
-       float miny = (float) min(min(newp[0].y,newp[1].y),min(newp[2].y,newp[3].y));
-       float maxx = (float) max(max(newp[0].x,newp[1].x),max(newp[2].x,newp[3].x));
-       float maxy = (float) max(max(newp[0].y,newp[1].y),max(newp[2].y,newp[3].y));
+       float minx = (float) __min(__min(newp[0].x,newp[1].x),__min(newp[2].x,newp[3].x));
+       float miny = (float) __min(__min(newp[0].y,newp[1].y),__min(newp[2].y,newp[3].y));
+       float maxx = (float) __max(__max(newp[0].x,newp[1].x),__max(newp[2].x,newp[3].x));
+       float maxy = (float) __max(__max(newp[0].y,newp[1].y),__max(newp[2].y,newp[3].y));
        int newWidth = (int) floor(maxx-minx+0.5f);
        int newHeight= (int) floor(maxy-miny+0.5f);
        float ssx=((maxx+minx)- ((float) newWidth-1))/2.0f;   //start for x
@@ -983,12 +983,12 @@ bool CxImage::Resample(long newx, long newy, int mode, CxImage* iDst)
                                if (info.nEscape) break;
                                fY = y * yScale;
                                ifY = (int)fY;
-                               ifY1 = min(ymax, ifY+1);
+                               ifY1 = __min(ymax, ifY+1);
                                dy = fY - ifY;
                                for(long x=0; x<newx; x++){
                                        fX = x * xScale;
                                        ifX = (int)fX;
-                                       ifX1 = min(xmax, ifX+1);
+                                       ifX1 = __min(xmax, ifX+1);
                                        dx = fX - ifX;
                                        // Interpolate using the four nearest pixels in the source
                                        if (head.biClrUsed){
@@ -1308,9 +1308,9 @@ bool CxImage::DecreaseBpp(DWORD nbit, bool errordiffusion, RGBQUAD* ppal, DWORD
                                eb=(long)c.rgbBlue - (long)ce.rgbBlue;
 
                                c = GetPixelColor(x+1,y);
-                               c.rgbRed = (BYTE)min(255L,max(0L,(long)c.rgbRed + ((er*7)/16)));
-                               c.rgbGreen = (BYTE)min(255L,max(0L,(long)c.rgbGreen + ((eg*7)/16)));
-                               c.rgbBlue = (BYTE)min(255L,max(0L,(long)c.rgbBlue + ((eb*7)/16)));
+                               c.rgbRed = (BYTE)__min(255L,__max(0L,(long)c.rgbRed + ((er*7)/16)));
+                               c.rgbGreen = (BYTE)__min(255L,__max(0L,(long)c.rgbGreen + ((eg*7)/16)));
+                               c.rgbBlue = (BYTE)__min(255L,__max(0L,(long)c.rgbBlue + ((eb*7)/16)));
                                SetPixelColor(x+1,y,c);
                                int coeff=1;
                                for(int i=-1; i<2; i++){
@@ -1323,9 +1323,9 @@ bool CxImage::DecreaseBpp(DWORD nbit, bool errordiffusion, RGBQUAD* ppal, DWORD
                                                coeff=1; break;
                                        }
                                        c = GetPixelColor(x+i,y+1);
-                                       c.rgbRed = (BYTE)min(255L,max(0L,(long)c.rgbRed + ((er * coeff)/16)));
-                                       c.rgbGreen = (BYTE)min(255L,max(0L,(long)c.rgbGreen + ((eg * coeff)/16)));
-                                       c.rgbBlue = (BYTE)min(255L,max(0L,(long)c.rgbBlue + ((eb * coeff)/16)));
+                                       c.rgbRed = (BYTE)__min(255L,__max(0L,(long)c.rgbRed + ((er * coeff)/16)));
+                                       c.rgbGreen = (BYTE)__min(255L,__max(0L,(long)c.rgbGreen + ((eg * coeff)/16)));
+                                       c.rgbBlue = (BYTE)__min(255L,__max(0L,(long)c.rgbBlue + ((eb * coeff)/16)));
                                        SetPixelColor(x+i,y+1,c);
                                }
                        }
@@ -1546,10 +1546,10 @@ bool CxImage::Dither(long method)
                                }
 
                                nlevel = GetPixelIndex(x + 1, y) + (error * 8) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(x + 1, y, level);
                                nlevel = GetPixelIndex(x + 2, y) + (error * 4) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(x + 2, y, level);
                                int i;
                                for (i = -2; i < 3; i++) {
@@ -1571,7 +1571,7 @@ bool CxImage::Dither(long method)
                                                break;
                                        }
                                        nlevel = GetPixelIndex(x + i, y + 1) + (error * coeff) / TotalCoeffSum;
-                                       level = (BYTE)min(255, max(0, (int)nlevel));
+                                       level = (BYTE)__min(255, __max(0, (int)nlevel));
                                        SetPixelIndex(x + i, y + 1, level);
                                }
                        }
@@ -1600,10 +1600,10 @@ bool CxImage::Dither(long method)
                                }
 
                                nlevel = GetPixelIndex(x + 1, y) + (error * 8) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(x + 1, y, level);
                                nlevel = GetPixelIndex(x + 2, y) + (error * 4) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(x + 2, y, level);
                                int i;
                                for (i = -2; i < 3; i++) {
@@ -1625,7 +1625,7 @@ bool CxImage::Dither(long method)
                                                break;
                                        }
                                        nlevel = GetPixelIndex(x + i, y + 1) + (error * coeff) / TotalCoeffSum;
-                                       level = (BYTE)min(255, max(0, (int)nlevel));
+                                       level = (BYTE)__min(255, __max(0, (int)nlevel));
                                        SetPixelIndex(x + i, y + 1, level);
                                }
                                for (i = -2; i < 3; i++) {
@@ -1647,7 +1647,7 @@ bool CxImage::Dither(long method)
                                                break;
                                        }
                                        nlevel = GetPixelIndex(x + i, y + 2) + (error * coeff) / TotalCoeffSum;
-                                       level = (BYTE)min(255, max(0, (int)nlevel));
+                                       level = (BYTE)__min(255, __max(0, (int)nlevel));
                                        SetPixelIndex(x + i, y + 2, level);
                                }
                        }
@@ -1676,10 +1676,10 @@ bool CxImage::Dither(long method)
                                }
 
                                nlevel = GetPixelIndex(x + 1, y) + (error * 7) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(x + 1, y, level);
                                nlevel = GetPixelIndex(x + 2, y) + (error * 5) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(x + 2, y, level);
                                int i;
                                for (i = -2; i < 3; i++) {
@@ -1701,7 +1701,7 @@ bool CxImage::Dither(long method)
                                                break;
                                        }
                                        nlevel = GetPixelIndex(x + i, y + 1) + (error * coeff) / TotalCoeffSum;
-                                       level = (BYTE)min(255, max(0, (int)nlevel));
+                                       level = (BYTE)__min(255, __max(0, (int)nlevel));
                                        SetPixelIndex(x + i, y + 1, level);
                                }
                                for (i = -2; i < 3; i++) {
@@ -1723,7 +1723,7 @@ bool CxImage::Dither(long method)
                                                break;
                                        }
                                        nlevel = GetPixelIndex(x + i, y + 2) + (error * coeff) / TotalCoeffSum;
-                                       level = (BYTE)min(255, max(0, (int)nlevel));
+                                       level = (BYTE)__min(255, __max(0, (int)nlevel));
                                        SetPixelIndex(x + i, y + 2, level);
                                }
                        }
@@ -1752,10 +1752,10 @@ bool CxImage::Dither(long method)
                                }
 
                                nlevel = GetPixelIndex(x + 1, y) + (error * 5) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(x + 1, y, level);
                                nlevel = GetPixelIndex(x + 2, y) + (error * 3) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(x + 2, y, level);
                                int i;
                                for (i = -2; i < 3; i++) {
@@ -1777,7 +1777,7 @@ bool CxImage::Dither(long method)
                                                break;
                                        }
                                        nlevel = GetPixelIndex(x + i, y + 1) + (error * coeff) / TotalCoeffSum;
-                                       level = (BYTE)min(255, max(0, (int)nlevel));
+                                       level = (BYTE)__min(255, __max(0, (int)nlevel));
                                        SetPixelIndex(x + i, y + 1, level);
                                }
                                for (i = -1; i < 2; i++) {
@@ -1793,7 +1793,7 @@ bool CxImage::Dither(long method)
                                                break;
                                        }
                                        nlevel = GetPixelIndex(x + i, y + 2) + (error * coeff) / TotalCoeffSum;
-                                       level = (BYTE)min(255, max(0, (int)nlevel));
+                                       level = (BYTE)__min(255, __max(0, (int)nlevel));
                                        SetPixelIndex(x + i, y + 2, level);
                                }
                        }
@@ -1825,76 +1825,76 @@ bool CxImage::Dither(long method)
                                int tmp_index_y = y;
                                int tmp_coeff = 32;
                                nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(tmp_index_x, tmp_index_y, level);
 
                                tmp_index_x = x - 3;
                                tmp_index_y = y + 1;
                                tmp_coeff = 12;
                                nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(tmp_index_x, tmp_index_y, level);
 
                                tmp_index_x = x - 1;
                                tmp_coeff = 26;
                                nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(tmp_index_x, tmp_index_y, level);
 
                                tmp_index_x = x + 1;
                                tmp_coeff = 30;
                                nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(tmp_index_x, tmp_index_y, level);
 
                                tmp_index_x = x + 3;
                                tmp_coeff = 16;
                                nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(tmp_index_x, tmp_index_y, level);
 
                                tmp_index_x = x - 2;
                                tmp_index_y = y + 2;
                                tmp_coeff = 12;
                                nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(tmp_index_x, tmp_index_y, level);
 
                                tmp_index_x = x;
                                tmp_coeff = 26;
                                nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(tmp_index_x, tmp_index_y, level);
 
                                tmp_index_x = x + 2;
                                tmp_coeff = 12;
                                nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(tmp_index_x, tmp_index_y, level);
 
                                tmp_index_x = x - 3;
                                tmp_index_y = y + 3;
                                tmp_coeff = 5;
                                nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(tmp_index_x, tmp_index_y, level);
 
                                tmp_index_x = x - 1;
                                tmp_coeff = 12;
                                nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(tmp_index_x, tmp_index_y, level);
 
                                tmp_index_x = x + 1;
                                tmp_coeff = 12;
                                nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(tmp_index_x, tmp_index_y, level);
 
                                tmp_index_x = x + 3;
                                tmp_coeff = 5;
                                nlevel = GetPixelIndex(tmp_index_x, tmp_index_y) + (error * tmp_coeff) / TotalCoeffSum;
-                               level = (BYTE)min(255, max(0, (int)nlevel));
+                               level = (BYTE)__min(255, __max(0, (int)nlevel));
                                SetPixelIndex(tmp_index_x, tmp_index_y, level);
                        }
                }
@@ -1921,7 +1921,7 @@ bool CxImage::Dither(long method)
                        Bmatrix[i] = (BYTE)(dither);
                }
 
-               int scale = max(0,(8-2*order));
+               int scale = __max(0,(8-2*order));
                int level;
                for (long y=0;y<head.biHeight;y++){
                        info.nProgress = (long)(100*y/head.biHeight);
@@ -1961,7 +1961,7 @@ bool CxImage::Dither(long method)
                                }
 
                                nlevel = GetPixelIndex(x+1,y) + (error * 7)/16;
-                               level = (BYTE)min(255,max(0,(int)nlevel));
+                               level = (BYTE)__min(255,__max(0,(int)nlevel));
                                SetPixelIndex(x+1,y,level);
                                for(int i=-1; i<2; i++){
                                        switch(i){
@@ -1973,7 +1973,7 @@ bool CxImage::Dither(long method)
                                                coeff=1; break;
                                        }
                                        nlevel = GetPixelIndex(x+i,y+1) + (error * coeff)/16;
-                                       level = (BYTE)min(255,max(0,(int)nlevel));
+                                       level = (BYTE)__min(255,__max(0,(int)nlevel));
                                        SetPixelIndex(x+i,y+1,level);
                                }
                        }
@@ -2011,7 +2011,7 @@ bool CxImage::CropRotatedRectangle( long topx, long topy, long width, long heigh
        if ( fabs(angle)<0.0002 )
                return Crop( topx, topy, topx+width, topy+height, iDst);
 
-       startx = min(topx, topx - (long)(sin_angle*(double)height));
+       startx = __min(topx, topx - (long)(sin_angle*(double)height));
        endx   = topx + (long)(cos_angle*(double)width);
        endy   = topy + (long)(cos_angle*(double)height + sin_angle*(double)width);
        // check: corners of the rectangle must be inside
@@ -2059,10 +2059,10 @@ bool CxImage::Crop(long left, long top, long right, long bottom, CxImage* iDst)
 {
        if (!pDib) return false;
 
-       long startx = max(0L,min(left,head.biWidth));
-       long endx = max(0L,min(right,head.biWidth));
-       long starty = head.biHeight - max(0L,min(top,head.biHeight));
-       long endy = head.biHeight - max(0L,min(bottom,head.biHeight));
+       long startx = __max(0L,__min(left,head.biWidth));
+       long endx = __max(0L,__min(right,head.biWidth));
+       long starty = head.biHeight - __max(0L,__min(top,head.biHeight));
+       long endy = head.biHeight - __max(0L,__min(bottom,head.biHeight));
 
        if (startx==endx || starty==endy) return false;