diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-04-16 23:10:45 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-04-17 03:56:59 +0200 |
commit | ea9904c89608d561f6bde3379408208bbb24fe35 (patch) | |
tree | 4648cbc73b7a48ea3361f51280a9713be38f0afd /vcl/source/bitmap | |
parent | 0957ee9f5d379c80fca4027c187b471118d0490d (diff) |
Drop FRound, and use generalized basegfx::fround
Change-Id: I7447e649dc3ef4e51242f69c7486a3e84e103d2e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166159
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl/source/bitmap')
-rw-r--r-- | vcl/source/bitmap/BitmapEmbossGreyFilter.cxx | 4 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapFastScaleFilter.cxx | 4 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx | 4 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx | 8 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapScaleSuperFilter.cxx | 4 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapTools.cxx | 8 | ||||
-rw-r--r-- | vcl/source/bitmap/Vectorizer.cxx | 6 | ||||
-rw-r--r-- | vcl/source/bitmap/bitmap.cxx | 16 |
8 files changed, 27 insertions, 27 deletions
diff --git a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx index 6fa5dd5c12b3..37c60e1b341a 100644 --- a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx +++ b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx @@ -47,7 +47,7 @@ BitmapEx BitmapEmbossGreyFilter::execute(BitmapEx const& rBitmapEx) const const double nLz = sin(fElev) * 255.0; const double nNz = 6 * 255.0 / 4; const double nNzLz = nNz * nLz; - const sal_uInt8 cLz = FRound(std::clamp(nLz, 0.0, 255.0)); + const sal_uInt8 cLz = basegfx::fround<sal_uInt8>(nLz); // fill mapping tables pHMap[0] = 0; @@ -97,7 +97,7 @@ BitmapEx BitmapEmbossGreyFilter::execute(BitmapEx const& rBitmapEx) const else { const double fGrey = nDotL / std::hypot(nNx, nNy, nNz); - aGrey.SetIndex(FRound(std::clamp(fGrey, 0.0, 255.0))); + aGrey.SetIndex(basegfx::fround<sal_uInt8>(fGrey)); } pWriteAcc->SetPixelOnData(pScanline, nX, aGrey); diff --git a/vcl/source/bitmap/BitmapFastScaleFilter.cxx b/vcl/source/bitmap/BitmapFastScaleFilter.cxx index 431211369f98..584942457f74 100644 --- a/vcl/source/bitmap/BitmapFastScaleFilter.cxx +++ b/vcl/source/bitmap/BitmapFastScaleFilter.cxx @@ -32,8 +32,8 @@ BitmapEx BitmapFastScaleFilter::execute(BitmapEx const& rBitmapEx) const Bitmap aBitmap(rBitmapEx.GetBitmap()); const Size aSizePix(aBitmap.GetSizePixel()); - const sal_Int32 nNewWidth = FRound(aSizePix.Width() * mfScaleX); - const sal_Int32 nNewHeight = FRound(aSizePix.Height() * mfScaleY); + const sal_Int32 nNewWidth = basegfx::fround(aSizePix.Width() * mfScaleX); + const sal_Int32 nNewHeight = basegfx::fround(aSizePix.Height() * mfScaleY); bool bRet = false; SAL_INFO("vcl.gdi", "New width: " << nNewWidth << "\nNew height: " << nNewHeight); diff --git a/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx b/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx index c0c866b53d67..f4547677f23e 100644 --- a/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx +++ b/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx @@ -31,8 +31,8 @@ BitmapEx BitmapInterpolateScaleFilter::execute(BitmapEx const& rBitmapEx) const Bitmap aBitmap(rBitmapEx.GetBitmap()); const Size aSizePix(aBitmap.GetSizePixel()); - const sal_Int32 nNewWidth = FRound(aSizePix.Width() * mfScaleX); - const sal_Int32 nNewHeight = FRound(aSizePix.Height() * mfScaleY); + const sal_Int32 nNewWidth = basegfx::fround(aSizePix.Width() * mfScaleX); + const sal_Int32 nNewHeight = basegfx::fround(aSizePix.Height() * mfScaleY); bool bRet = false; if ((nNewWidth > 1) && (nNewHeight > 1)) diff --git a/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx index 27df45f7bab1..56b2f3969a9e 100644 --- a/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx +++ b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx @@ -90,7 +90,7 @@ bool ImplScaleConvolutionHor(Bitmap& rSource, Bitmap& rTarget, const double& rSc // Do horizontal filtering OSL_ENSURE(rScaleX > 0.0, "Error in scaling: Mirror given in non-mirror-capable method (!)"); const sal_Int32 nWidth(rSource.GetSizePixel().Width()); - const sal_Int32 nNewWidth(FRound(nWidth * rScaleX)); + const sal_Int32 nNewWidth(basegfx::fround(nWidth * rScaleX)); if(nWidth == nNewWidth) { @@ -180,7 +180,7 @@ bool ImplScaleConvolutionVer(Bitmap& rSource, Bitmap& rTarget, const double& rSc // Do vertical filtering OSL_ENSURE(rScaleY > 0.0, "Error in scaling: Mirror given in non-mirror-capable method (!)"); const sal_Int32 nHeight(rSource.GetSizePixel().Height()); - const sal_Int32 nNewHeight(FRound(nHeight * rScaleY)); + const sal_Int32 nNewHeight(basegfx::fround(nHeight * rScaleY)); if(nHeight == nNewHeight) { @@ -263,8 +263,8 @@ bool ImplScaleConvolution(Bitmap& rBitmap, const double& rScaleX, const double& const double fScaleY(bMirrorVer ? -rScaleY : rScaleY); const sal_Int32 nWidth(rBitmap.GetSizePixel().Width()); const sal_Int32 nHeight(rBitmap.GetSizePixel().Height()); - const sal_Int32 nNewWidth(FRound(nWidth * fScaleX)); - const sal_Int32 nNewHeight(FRound(nHeight * fScaleY)); + const sal_Int32 nNewWidth(basegfx::fround(nWidth * fScaleX)); + const sal_Int32 nNewHeight(basegfx::fround(nHeight * fScaleY)); const bool bScaleHor(nWidth != nNewWidth); const bool bScaleVer(nHeight != nNewHeight); const bool bMirror(bMirrorHor || bMirrorVer); diff --git a/vcl/source/bitmap/BitmapScaleSuperFilter.cxx b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx index 3c844c690e7e..1b13fb817d1b 100644 --- a/vcl/source/bitmap/BitmapScaleSuperFilter.cxx +++ b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx @@ -870,8 +870,8 @@ BitmapEx BitmapScaleSuperFilter::execute(BitmapEx const& rBitmap) const double fScaleX = std::fabs(mrScaleX); double fScaleY = std::fabs(mrScaleY); - const sal_Int32 nDstW = FRound(aSizePix.Width() * fScaleX); - const sal_Int32 nDstH = FRound(aSizePix.Height() * fScaleY); + const sal_Int32 nDstW = basegfx::fround(aSizePix.Width() * fScaleX); + const sal_Int32 nDstH = basegfx::fround(aSizePix.Height() * fScaleY); constexpr double fScaleThresh = 0.6; diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index 4045a107c814..204e61b57073 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -1396,13 +1396,13 @@ Bitmap GetDownsampledBitmap(Size const& rDstSizeTwip, Point const& rSrcPt, Size if (fBmpWH < fMaxWH) { - aNewBmpSize.setWidth(FRound(fMaxPixelY * fBmpWH)); - aNewBmpSize.setHeight(FRound(fMaxPixelY)); + aNewBmpSize.setWidth(basegfx::fround<tools::Long>(fMaxPixelY * fBmpWH)); + aNewBmpSize.setHeight(basegfx::fround<tools::Long>(fMaxPixelY)); } else if (fBmpWH > 0.0) { - aNewBmpSize.setWidth(FRound(fMaxPixelX)); - aNewBmpSize.setHeight(FRound(fMaxPixelX / fBmpWH)); + aNewBmpSize.setWidth(basegfx::fround<tools::Long>(fMaxPixelX)); + aNewBmpSize.setHeight(basegfx::fround<tools::Long>(fMaxPixelX / fBmpWH)); } if( aNewBmpSize.Width() && aNewBmpSize.Height() ) diff --git a/vcl/source/bitmap/Vectorizer.cxx b/vcl/source/bitmap/Vectorizer.cxx index f385fa36cacb..d54046215122 100644 --- a/vcl/source/bitmap/Vectorizer.cxx +++ b/vcl/source/bitmap/Vectorizer.cxx @@ -687,7 +687,7 @@ bool Vectorizer::vectorize(BitmapEx const& rBitmap, GDIMetaFile& rMetafile) fPercentStep_2 = 45.0 / n; fPercent += 10.0; - updateProgress(FRound(fPercent)); + updateProgress(basegfx::fround<tools::Long>(fPercent)); for( sal_uInt16 i = 0; i < n; i++ ) { @@ -697,7 +697,7 @@ bool Vectorizer::vectorize(BitmapEx const& rBitmap, GDIMetaFile& rMetafile) ImplExpand( oMap, pRAcc.get(), aFindColor ); fPercent += fPercentStep_2; - updateProgress(FRound(fPercent)); + updateProgress(basegfx::fround<tools::Long>(fPercent)); if( oMap ) { @@ -721,7 +721,7 @@ bool Vectorizer::vectorize(BitmapEx const& rBitmap, GDIMetaFile& rMetafile) } fPercent += fPercentStep_2; - updateProgress(FRound(fPercent)); + updateProgress(basegfx::fround<tools::Long>(fPercent)); } if (rMetafile.GetActionSize()) diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx index 914e49295524..38a3a90c09dc 100644 --- a/vcl/source/bitmap/bitmap.cxx +++ b/vcl/source/bitmap/bitmap.cxx @@ -340,8 +340,8 @@ void Bitmap::ReassignWithSize(const Bitmap& rBitmap) if ((aOldSizePix != aNewSizePix) && aOldSizePix.Width() && aOldSizePix.Height()) { - aNewPrefSize.setWidth(FRound(maPrefSize.Width() * aNewSizePix.Width() / aOldSizePix.Width())); - aNewPrefSize.setHeight(FRound(maPrefSize.Height() * aNewSizePix.Height() / aOldSizePix.Height())); + aNewPrefSize.setWidth(maPrefSize.Width() * aNewSizePix.Width() / aOldSizePix.Width()); + aNewPrefSize.setHeight(maPrefSize.Height() * aNewSizePix.Height() / aOldSizePix.Height()); } else { @@ -1505,18 +1505,18 @@ bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent, { if(!msoBrightness) { - cMapR[ nX ] = FRound( std::clamp( nX * fM + fROff, 0.0, 255.0 ) ); - cMapG[ nX ] = FRound( std::clamp( nX * fM + fGOff, 0.0, 255.0 ) ); - cMapB[ nX ] = FRound( std::clamp( nX * fM + fBOff, 0.0, 255.0 ) ); + cMapR[nX] = basegfx::fround<sal_uInt8>(nX * fM + fROff); + cMapG[nX] = basegfx::fround<sal_uInt8>(nX * fM + fGOff); + cMapB[nX] = basegfx::fround<sal_uInt8>(nX * fM + fBOff); } else { // LO simply uses (in a somewhat optimized form) "newcolor = (oldcolor-128)*contrast+brightness+128" // as the formula, i.e. contrast first, brightness afterwards. MSOffice, for whatever weird reason, // use neither first, but apparently it applies half of brightness before contrast and half afterwards. - cMapR[ nX ] = FRound( std::clamp( (nX+fROff/2-128) * fM + 128 + fROff/2, 0.0, 255.0 ) ); - cMapG[ nX ] = FRound( std::clamp( (nX+fGOff/2-128) * fM + 128 + fGOff/2, 0.0, 255.0 ) ); - cMapB[ nX ] = FRound( std::clamp( (nX+fBOff/2-128) * fM + 128 + fBOff/2, 0.0, 255.0 ) ); + cMapR[nX] = basegfx::fround<sal_uInt8>((nX + fROff / 2 - 128) * fM + 128 + fROff / 2); + cMapG[nX] = basegfx::fround<sal_uInt8>((nX + fGOff / 2 - 128) * fM + 128 + fGOff / 2); + cMapB[nX] = basegfx::fround<sal_uInt8>((nX + fBOff / 2 - 128) * fM + 128 + fBOff / 2); } if( bGamma ) { |