tools/source/generic/color.cxx | 19 ++++++++++--------- vcl/source/bitmap/BitmapEmbossGreyFilter.cxx | 7 +++++-- vcl/source/bitmap/BitmapSepiaFilter.cxx | 6 +++++- vcl/source/bitmap/BitmapSobelGreyFilter.cxx | 5 ++++- 4 files changed, 24 insertions(+), 13 deletions(-)
New commits: commit a3e725b896d692da39922dc41bed93fcb9dafae0 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Sun Nov 11 10:40:54 2018 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Sun Nov 11 18:11:04 2018 +0100 Replace uses of SAL_BOUND with o3tl::clamp Change-Id: I66a7aad64623d778b4bf2fea591f227fdac2fdc7 Reviewed-on: https://gerrit.libreoffice.org/63264 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx index a0d409d6e76c..9b03e0916d84 100644 --- a/tools/source/generic/color.cxx +++ b/tools/source/generic/color.cxx @@ -23,6 +23,7 @@ #include <sstream> #include <stdlib.h> +#include <o3tl/clamp.hxx> #include <tools/color.hxx> #include <tools/stream.hxx> #include <tools/helpers.hxx> @@ -39,16 +40,16 @@ sal_uInt8 Color::GetColorError( const Color& rCompareColor ) const void Color::IncreaseLuminance( sal_uInt8 cLumInc ) { - SetRed( static_cast<sal_uInt8>(SAL_BOUND( static_cast<long>(COLORDATA_RED( mnColor )) + cLumInc, 0L, 255L )) ); - SetGreen( static_cast<sal_uInt8>(SAL_BOUND( static_cast<long>(COLORDATA_GREEN( mnColor )) + cLumInc, 0L, 255L )) ); - SetBlue( static_cast<sal_uInt8>(SAL_BOUND( static_cast<long>(COLORDATA_BLUE( mnColor )) + cLumInc, 0L, 255L )) ); + SetRed( static_cast<sal_uInt8>(o3tl::clamp( static_cast<long>(COLORDATA_RED( mnColor )) + cLumInc, 0L, 255L )) ); + SetGreen( static_cast<sal_uInt8>(o3tl::clamp( static_cast<long>(COLORDATA_GREEN( mnColor )) + cLumInc, 0L, 255L )) ); + SetBlue( static_cast<sal_uInt8>(o3tl::clamp( static_cast<long>(COLORDATA_BLUE( mnColor )) + cLumInc, 0L, 255L )) ); } void Color::DecreaseLuminance( sal_uInt8 cLumDec ) { - SetRed( static_cast<sal_uInt8>(SAL_BOUND( static_cast<long>(COLORDATA_RED( mnColor )) - cLumDec, 0L, 255L )) ); - SetGreen( static_cast<sal_uInt8>(SAL_BOUND( static_cast<long>(COLORDATA_GREEN( mnColor )) - cLumDec, 0L, 255L )) ); - SetBlue( static_cast<sal_uInt8>(SAL_BOUND( static_cast<long>(COLORDATA_BLUE( mnColor )) - cLumDec, 0L, 255L )) ); + SetRed( static_cast<sal_uInt8>(o3tl::clamp( static_cast<long>(COLORDATA_RED( mnColor )) - cLumDec, 0L, 255L )) ); + SetGreen( static_cast<sal_uInt8>(o3tl::clamp( static_cast<long>(COLORDATA_GREEN( mnColor )) - cLumDec, 0L, 255L )) ); + SetBlue( static_cast<sal_uInt8>(o3tl::clamp( static_cast<long>(COLORDATA_BLUE( mnColor )) - cLumDec, 0L, 255L )) ); } void Color::DecreaseContrast( sal_uInt8 cContDec ) @@ -58,9 +59,9 @@ void Color::DecreaseContrast( sal_uInt8 cContDec ) const double fM = ( 128.0 - 0.4985 * cContDec ) / 128.0; const double fOff = 128.0 - fM * 128.0; - SetRed( static_cast<sal_uInt8>(SAL_BOUND( FRound( COLORDATA_RED( mnColor ) * fM + fOff ), 0L, 255L )) ); - SetGreen( static_cast<sal_uInt8>(SAL_BOUND( FRound( COLORDATA_GREEN( mnColor ) * fM + fOff ), 0L, 255L )) ); - SetBlue( static_cast<sal_uInt8>(SAL_BOUND( FRound( COLORDATA_BLUE( mnColor ) * fM + fOff ), 0L, 255L )) ); + SetRed( static_cast<sal_uInt8>(o3tl::clamp( FRound( COLORDATA_RED( mnColor ) * fM + fOff ), 0L, 255L )) ); + SetGreen( static_cast<sal_uInt8>(o3tl::clamp( FRound( COLORDATA_GREEN( mnColor ) * fM + fOff ), 0L, 255L )) ); + SetBlue( static_cast<sal_uInt8>(o3tl::clamp( FRound( COLORDATA_BLUE( mnColor ) * fM + fOff ), 0L, 255L )) ); } } diff --git a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx index 2c182463367d..9fdf7aac4bc4 100644 --- a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx +++ b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx @@ -8,6 +8,9 @@ * */ +#include <sal/config.h> + +#include <o3tl/clamp.hxx> #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/bitmapaccess.hxx> @@ -50,7 +53,7 @@ BitmapEx BitmapEmbossGreyFilter::execute(BitmapEx const& rBitmapEx) const const long nLz = FRound(sin(fElev) * 255.0); const auto nZ2 = ((6 * 255) / 4) * ((6 * 255) / 4); const long nNzLz = ((6 * 255) / 4) * nLz; - const sal_uInt8 cLz = static_cast<sal_uInt8>(SAL_BOUND(nLz, 0, 255)); + const sal_uInt8 cLz = static_cast<sal_uInt8>(o3tl::clamp(nLz, 0L, 255L)); // fill mapping tables pHMap[0] = 0; @@ -101,7 +104,7 @@ BitmapEx BitmapEmbossGreyFilter::execute(BitmapEx const& rBitmapEx) const { const double fGrey = nDotL / sqrt(static_cast<double>(nNx * nNx + nNy * nNy + nZ2)); - aGrey.SetIndex(static_cast<sal_uInt8>(SAL_BOUND(fGrey, 0, 255))); + aGrey.SetIndex(static_cast<sal_uInt8>(o3tl::clamp(fGrey, 0.0, 255.0))); } pWriteAcc->SetPixelOnData(pScanline, nX, aGrey); diff --git a/vcl/source/bitmap/BitmapSepiaFilter.cxx b/vcl/source/bitmap/BitmapSepiaFilter.cxx index 9e2aaeaac31d..6df4fe1b5221 100644 --- a/vcl/source/bitmap/BitmapSepiaFilter.cxx +++ b/vcl/source/bitmap/BitmapSepiaFilter.cxx @@ -8,6 +8,9 @@ * */ +#include <sal/config.h> + +#include <o3tl/clamp.hxx> #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/bitmapaccess.hxx> @@ -23,7 +26,8 @@ BitmapEx BitmapSepiaFilter::execute(BitmapEx const& rBitmapEx) const if (pReadAcc) { - const long nSepia = 10000 - 100 * SAL_BOUND(mnSepiaPercent, 0, 100); + const long nSepia + = 10000 - 100 * o3tl::clamp(mnSepiaPercent, sal_uInt16(0), sal_uInt16(100)); BitmapPalette aSepiaPal(256); for (sal_uInt16 i = 0; i < 256; i++) diff --git a/vcl/source/bitmap/BitmapSobelGreyFilter.cxx b/vcl/source/bitmap/BitmapSobelGreyFilter.cxx index 47c6f438f995..a631fe4f30a2 100644 --- a/vcl/source/bitmap/BitmapSobelGreyFilter.cxx +++ b/vcl/source/bitmap/BitmapSobelGreyFilter.cxx @@ -8,6 +8,9 @@ * */ +#include <sal/config.h> + +#include <o3tl/clamp.hxx> #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/bitmapaccess.hxx> @@ -116,7 +119,7 @@ BitmapEx BitmapSobelGreyFilter::execute(BitmapEx const& rBitmapEx) const nSum1 = static_cast<long>( sqrt(static_cast<double>(nSum1 * nSum1 + nSum2 * nSum2))); - aGrey.SetIndex(~static_cast<sal_uInt8>(SAL_BOUND(nSum1, 0, 255))); + aGrey.SetIndex(~static_cast<sal_uInt8>(o3tl::clamp(nSum1, 0L, 255L))); pWriteAcc->SetPixelOnData(pScanline, nX, aGrey); if (nX < (nWidth - 1)) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits