From 4b234ab9b3e5590e6222f088fffd3ab614eeca49 Mon Sep 17 00:00:00 2001 From: Simon Rit Date: Tue, 2 Jan 2018 16:11:52 +0100 Subject: [PATCH] COMP: renamed min max macros which are no longer allowed 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 | 8 +- utilities/CxImage/ximage.cpp | 4 +- utilities/CxImage/ximagif.cpp | 6 +- utilities/CxImage/ximaint.cpp | 8 +- utilities/CxImage/ximaiter.h | 4 +- utilities/CxImage/ximapal.cpp | 14 ++-- utilities/CxImage/ximasel.cpp | 50 ++++++------ utilities/CxImage/ximath.cpp | 8 +- utilities/CxImage/ximatran.cpp | 134 ++++++++++++++++----------------- 9 files changed, 118 insertions(+), 118 deletions(-) diff --git a/utilities/CxImage/ximadef.h b/utilities/CxImage/ximadef.h index b388b2b..e4bf05e 100644 --- a/utilities/CxImage/ximadef.h +++ b/utilities/CxImage/ximadef.h @@ -53,11 +53,11 @@ #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 diff --git a/utilities/CxImage/ximage.cpp b/utilities/CxImage/ximage.cpp index e81d3c6..1b94d3b 100644 --- a/utilities/CxImage/ximage.cpp +++ b/utilities/CxImage/ximage.cpp @@ -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)); } } } diff --git a/utilities/CxImage/ximagif.cpp b/utilities/CxImage/ximagif.cpp index 0c89759..16fd3a5 100644 --- a/utilities/CxImage/ximagif.cpp +++ b/utilities/CxImage/ximagif.cpp @@ -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; diff --git a/utilities/CxImage/ximaint.cpp b/utilities/CxImage/ximaint.cpp index c30e882..96b445a 100644 --- a/utilities/CxImage/ximaint.cpp +++ b/utilities/CxImage/ximaint.cpp @@ -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 diff --git a/utilities/CxImage/ximaiter.h b/utilities/CxImage/ximaiter.h index 9788919..cd5c266 100644 --- a/utilities/CxImage/ximaiter.h +++ b/utilities/CxImage/ximaiter.h @@ -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() diff --git a/utilities/CxImage/ximapal.cpp b/utilities/CxImage/ximapal.cpp index b3bd3da..192776c 100644 --- a/utilities/CxImage/ximapal.cpp +++ b/utilities/CxImage/ximapal.cpp @@ -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 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 (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; yx < 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); diff --git a/utilities/CxImage/ximath.cpp b/utilities/CxImage/ximath.cpp index 37533e2..8d8cf13 100644 --- a/utilities/CxImage/ximath.cpp +++ b/utilities/CxImage/ximath.cpp @@ -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 { diff --git a/utilities/CxImage/ximatran.cpp b/utilities/CxImage/ximatran.cpp index d3aac01..dd635cf 100644 --- a/utilities/CxImage/ximatran.cpp +++ b/utilities/CxImage/ximatran.cpp @@ -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); // 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); // 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); // 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