From kde-commits Sat Sep 29 04:31:49 2018 From: Human Dynamo Date: Sat, 29 Sep 2018 04:31:49 +0000 To: kde-commits Subject: [digikam] core/libs/dimg/filters/transform: fix clang warnings Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=153819780800997 Git commit 03c15c51ee4ef171bca20479f6ab32ebbc20ba1c by Human Dynamo. Committed on 29/09/2018 at 04:31. Pushed by cgilles into branch 'master'. fix clang warnings M +86 -73 core/libs/dimg/filters/transform/autocrop.cpp M +3 -3 core/libs/dimg/filters/transform/autocrop.h https://commits.kde.org/digikam/03c15c51ee4ef171bca20479f6ab32ebbc20ba1c diff --git a/core/libs/dimg/filters/transform/autocrop.cpp b/core/libs/dimg= /filters/transform/autocrop.cpp index 10282d4792..2181fc5d74 100644 --- a/core/libs/dimg/filters/transform/autocrop.cpp +++ b/core/libs/dimg/filters/transform/autocrop.cpp @@ -76,22 +76,22 @@ QRect AutoCrop::spiralClockwiseTraversal(const QImage& = source, int topCrop, int = if (topCrop =3D=3D -1) { - topCrop=3D0; + topCrop =3D 0; } = if (bottomCrop =3D=3D -1) { - bottomCrop=3Dsource.height(); + bottomCrop =3D source.height(); } = - QSize resultsize =3D QSize(source.width(),(source.height()-topCrop-(so= urce.height()-bottomCrop))); + QSize resultsize =3D QSize(source.width(), (source.height() - topCrop = - (source.height() - bottomCrop))); QImage threshold =3D QImage(resultsize, QImage::Format_RGB888); = for (i =3D topCrop, ni =3D 0 ; i < bottomCrop ; ++i, ++ni) { for (j =3D 0 ; j < source.width() ; ++j) { - threshold.setPixel(j,ni,source.pixel(j,i)); + threshold.setPixel(j, ni, source.pixel(j, i)); } } = @@ -129,7 +129,7 @@ QRect AutoCrop::spiralClockwiseTraversal(const QImage& = source, int topCrop, int bool fixrightmargin =3D false; bool fixleftmargin =3D false; bool fixbottommargin =3D false; -// int count =3D limitcolumn + limitrow -1; + //int count =3D limitcolumn + limitrow -1; bool rightEdge =3D false; bool leftEdge =3D false; bool topEdge =3D false; @@ -146,11 +146,11 @@ QRect AutoCrop::spiralClockwiseTraversal(const QImage= & source, int topCrop, int = while (true) { -// qCDebug(DIGIKAM_DIMG_LOG) << "count =3D "<=3D limitcolumn) { qCDebug(DIGIKAM_DIMG_LOG) << "We have reached limitcol= umn, i.e. width"; - endrightj =3D limitcolumn-1; + endrightj =3D limitcolumn - 1; fixrightmargin =3D true; - rightmargin =3D limitcolumn-1; + rightmargin =3D limitcolumn - 1; counter++; travelright--; rightEdge =3D true; @@ -198,10 +198,11 @@ QRect AutoCrop::spiralClockwiseTraversal(const QImage= & source, int topCrop, int = i =3D startrighti; j =3D startrightj; + (void)j; // Remove clang warnings. = for (j =3D startrightj + 1 ; j <=3D endrightj ; ++j) { -// qCDebug(DIGIKAM_DIMG_LOG) << "At pixel "<< j << " , = " << i; + //qCDebug(DIGIKAM_DIMG_LOG) << "At pixel "<< j << " , = " << i; c =3D QColor::fromRgb(threshold.pixel(j,i)); = if (c =3D=3D Qt::black) @@ -219,7 +220,8 @@ QRect AutoCrop::spiralClockwiseTraversal(const QImage& = source, int topCrop, int = break; } - case 1 : // traveling down + + case 1: // traveling down { if (fixrightmargin =3D=3D true) { @@ -230,13 +232,13 @@ QRect AutoCrop::spiralClockwiseTraversal(const QImage= & source, int topCrop, int if (enddowni >=3D limitrow) { fixbottommargin =3D true; - bottommargin =3D limitrow-1; + bottommargin =3D limitrow - 1; bottomEdge =3D true; } } = //endrightj--; - // qCDebug(DIGIKAM_DIMG_LOG) << "Traveling down : Case= Skipped\n"; + //qCDebug(DIGIKAM_DIMG_LOG) << "Traveling down : Case = Skipped\n"; break; } = @@ -251,20 +253,21 @@ QRect AutoCrop::spiralClockwiseTraversal(const QImage= & source, int topCrop, int startdowni =3D endrighti; startdownj =3D endrightj; enddowni =3D startdowni + traveldown; - // qCDebug(DIGIKAM_DIMG_LOG) << "Moving Down En= dDown =3D " << enddowni; + //qCDebug(DIGIKAM_DIMG_LOG) << "Moving Down EndDown =3D " = << enddowni; = if (enddowni >=3D limitrow) { qCDebug(DIGIKAM_DIMG_LOG) << "We have reached limitrow= , i.e. Height"; - enddowni =3D limitrow-1; + enddowni =3D limitrow - 1; counter++; - bottommargin =3D limitrow-1; + bottommargin =3D limitrow - 1; fixbottommargin =3D true; traveldown--; bottomEdge =3D true; } = i =3D startdowni; + (void)i; // Remove clang warning. j =3D startdownj; = for (i =3D startdowni + 1 ; i <=3D enddowni ; ++i) @@ -317,7 +320,7 @@ QRect AutoCrop::spiralClockwiseTraversal(const QImage& = source, int topCrop, int startlefti =3D enddowni; startleftj =3D enddownj; endleftj =3D startleftj - travelleft; - // qCDebug(DIGIKAM_DIMG_LOG) << "Moving Left En= dleft =3D " << endleftj; + //qCDebug(DIGIKAM_DIMG_LOG) << "Moving Left Endleft =3D " = << endleftj; = if (endleftj < 0) { @@ -332,10 +335,11 @@ QRect AutoCrop::spiralClockwiseTraversal(const QImage= & source, int topCrop, int = i =3D startlefti; j =3D startleftj; + (void)j; // Remove clang warning. = for (j =3D startleftj - 1 ; j >=3D endleftj ; --j) { -// qCDebug(DIGIKAM_DIMG_LOG) << "At pixel "<< j << " , = " << i; + //qCDebug(DIGIKAM_DIMG_LOG) << "At pixel "<< j << " , = " << i; c =3D QColor::fromRgb(threshold.pixel(j,i)); = if (c =3D=3D Qt::black) @@ -353,7 +357,8 @@ QRect AutoCrop::spiralClockwiseTraversal(const QImage& = source, int topCrop, int = break; } - case 3 : //traveling up + + case 3: //traveling up { if (fixleftmargin =3D=3D true) { @@ -384,7 +389,7 @@ QRect AutoCrop::spiralClockwiseTraversal(const QImage& = source, int topCrop, int startupi =3D endlefti; startupj =3D endleftj; endupi =3D startupi - travelup; - // qCDebug(DIGIKAM_DIMG_LOG) << "Moving Up Endu= p =3D " << endupi; + //qCDebug(DIGIKAM_DIMG_LOG) << "Moving Up Endup =3D " << e= ndupi; = if (endupi < 0) { @@ -398,11 +403,12 @@ QRect AutoCrop::spiralClockwiseTraversal(const QImage= & source, int topCrop, int } = i =3D startupi; + (void)i; // Remove clang warning. j =3D startupj; = for (i =3D startupi - 1 ; i >=3D endupi ; --i) { -// qCDebug(DIGIKAM_DIMG_LOG) << "At pixel "<< j << " , = " << i; + //qCDebug(DIGIKAM_DIMG_LOG) << "At pixel "<< j << " , = " << i; c =3D QColor::fromRgb(threshold.pixel(j, i)); = if (c =3D=3D Qt::black) @@ -440,19 +446,19 @@ QRect AutoCrop::spiralClockwiseTraversal(const QImage= & source, int topCrop, int qCDebug(DIGIKAM_DIMG_LOG) << "Enddownj : " << enddownj; qCDebug(DIGIKAM_DIMG_LOG) << "Endlefti : " << endlefti; qCDebug(DIGIKAM_DIMG_LOG) << "Endleftj : " << endleftj; - qCDebug(DIGIKAM_DIMG_LOG) << "Done\n"; + qCDebug(DIGIKAM_DIMG_LOG) << "Done" << endl; = qCDebug(DIGIKAM_DIMG_LOG) << "Left Margin : " << leftmargin; qCDebug(DIGIKAM_DIMG_LOG) << "Right Margin : " << rightmargin; qCDebug(DIGIKAM_DIMG_LOG) << "Top Margin : " << topmargin; qCDebug(DIGIKAM_DIMG_LOG) << "Bottom Margin : " << bottommargin; - qCDebug(DIGIKAM_DIMG_LOG) << "Done\n"; + qCDebug(DIGIKAM_DIMG_LOG) << "Done" << endl; = qCDebug(DIGIKAM_DIMG_LOG) << "Left Edge : " << leftEdge; qCDebug(DIGIKAM_DIMG_LOG) << "Right Edge : " << rightEdge; qCDebug(DIGIKAM_DIMG_LOG) << "Top Edge : " << topEdge; qCDebug(DIGIKAM_DIMG_LOG) << "Bottom Edge : " << bottomEdge; - qCDebug(DIGIKAM_DIMG_LOG) << "Done\n"; + qCDebug(DIGIKAM_DIMG_LOG) << "Done" << endl; = if (bottomEdge) { @@ -477,11 +483,11 @@ QRect AutoCrop::spiralClockwiseTraversal(const QImage= & source, int topCrop, int //----------------------releasing images = QPoint icp1; - icp1.setX(leftmargin+1); - icp1.setY(topCrop+topmargin+1); + icp1.setX(leftmargin + 1); + icp1.setY(topCrop + topmargin + 1); QPoint icp2; - icp2.setX(rightmargin-1); - icp2.setY(topCrop+bottommargin-1); + icp2.setX(rightmargin - 1); + icp2.setY(topCrop + bottommargin - 1); QRect cropArea; cropArea.setTopLeft(icp1); cropArea.setBottomRight(icp2); @@ -506,18 +512,18 @@ void AutoCrop::startAnalyse() = postProgress(5); = - //----------------------Finding the outer boundaries of the image (i.e= . with black portions) + //---------------------- Finding the outer boundaries of the image (i.= e. with black portions) = /* This would be done in 4 steps - 1. Search column wise: - (a) From the left to the right, this is to get the left bounda= ry - (b) From the right to the left, this is to get the right bound= ary - 2. Search row wise : - (a) From the top to the bottom, this is to get the top boundary - (b) From the bottom to the top, this is to get the bottom boun= dary - */ + * 1. Search column wise: + * (a) From the left to the right, this is to get the left bounda= ry + * (b) From the right to the left, this is to get the right bound= ary + * 2. Search row wise : + * (a) From the top to the bottom, this is to get the top boundary + * (b) From the bottom to the top, this is to get the bottom boun= dary + */ = - //1(a) Traversing the image from top to bottom, left to right, to get = left boundary + // 1(a) Traversing the image from top to bottom, left to right, to get= left boundary = breakflag =3D 0; int width =3D img.width(); @@ -553,6 +559,7 @@ void AutoCrop::startAnalyse() //1(b) Traversing the image from top to bottom, right to left, to get = right boundary = breakflag =3D 0; + (void)breakflag; // Remove clang warnings. = for (i =3D 0 ; i < width ; ++i) { @@ -577,7 +584,7 @@ void AutoCrop::startAnalyse() qCDebug(DIGIKAM_DIMG_LOG) << "Done Till step 1(b)"; postProgress(50); = - //2(a) Traversing the image left to right, top to down, to get top bou= ndary + // 2(a) Traversing the image left to right, top to down, to get top bo= undary = breakflag =3D 0; = @@ -608,7 +615,7 @@ void AutoCrop::startAnalyse() qCDebug(DIGIKAM_DIMG_LOG) << "Done Till step 2(a)"; postProgress(70); = - //2(b) Traversing the image from left to right, bottom up, to get lowe= r boundary + // 2(b) Traversing the image from left to right, bottom up, to get low= er boundary = breakflag =3D 0; = @@ -731,7 +738,7 @@ void AutoCrop::startAnalyse() = if (c !=3D Qt::black) { - toggleflag2=3Dj; + toggleflag2 =3D j; break; } } @@ -765,7 +772,7 @@ void AutoCrop::startAnalyse() = for (i =3D (result.height()-1) ; i >=3D 0 ; --i) { - c =3D QColor::fromRgb(result.pixel(j,i)); + c =3D QColor::fromRgb(result.pixel(j, i)); = if (c !=3D Qt::black) { @@ -813,19 +820,19 @@ void AutoCrop::startAnalyse() = QRect InrCrop =3D spiralClockwiseTraversal(threshold,-1,-1); QPoint icp1; - icp1.setX(InrCrop.topLeft().x()+leftColumn); - icp1.setY(InrCrop.topLeft().y()+topRow); + icp1.setX(InrCrop.topLeft().x() + leftColumn); + icp1.setY(InrCrop.topLeft().y() + topRow); QPoint icp2; - icp2.setX(InrCrop.bottomRight().x()+leftColumn); - icp2.setY(InrCrop.bottomRight().y()+topRow); + icp2.setX(InrCrop.bottomRight().x() + leftColumn); + icp2.setY(InrCrop.bottomRight().y() + topRow); QRect cropArea; cropArea.setTopLeft(icp1); cropArea.setBottomRight(icp2); = qCDebug(DIGIKAM_DIMG_LOG) << "cropArea : "<cropArea.setTopLeft(icp1); d->cropArea.setBottomRight(icp2); } @@ -1015,22 +1024,26 @@ void AutoCrop::startAnalyse() } = qCDebug(DIGIKAM_DIMG_LOG) << "Inner Crop Area : " << cropArea; -// return(cropArea); -// resultsize =3D QSize (cropArea.width(), cropArea.height()); -// QImage ic =3D QImage(resultsize,img.format()); -// for(i=3DcropArea.top(), ni=3D0 ; i<=3DcropArea.bottom() ; i++, ni++ ) -// { -// for (j=3DcropArea.left(), nj=3D0 ; j<=3DcropArea.right();j++,nj+= + ) -// { -// ic.setPixel(nj,ni,img.pixel(j,i)); -// } -// } -// qCDebug(DIGIKAM_DIMG_LOG) << "From "<cropArea; } = diff --git a/core/libs/dimg/filters/transform/autocrop.h b/core/libs/dimg/f= ilters/transform/autocrop.h index da1b0b3956..0a87b0c34e 100644 --- a/core/libs/dimg/filters/transform/autocrop.h +++ b/core/libs/dimg/filters/transform/autocrop.h @@ -59,16 +59,16 @@ public: */ QRect autoInnerCrop() const; = -private : +private: = /** Takes in a binary image and crops it on the basis of black point * detection, spirally moving outwards. * topCrop can be set to explicitly crop a upper portion of the image * bottomCrop can be set to explicitly crop a bottom portion of the i= mage */ - QRect spiralClockwiseTraversal(const QImage& source, int topCrop=3D-1,= int bottomCrop=3D-1); + QRect spiralClockwiseTraversal(const QImage& source, int topCrop =3D -= 1, int bottomCrop =3D -1); = -private : +private: = class Private; Private* d;