summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-11-11 10:40:54 +0100
committerStephan Bergmann <sbergman@redhat.com>2018-11-11 18:11:04 +0100
commita3e725b896d692da39922dc41bed93fcb9dafae0 (patch)
treea733828ce0dbee28d29832d8597854b6fdec2287 /tools
parentb9b7f98befb722e59bd84bc9975a4ec381616abc (diff)
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 <sbergman@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/generic/color.cxx19
1 files changed, 10 insertions, 9 deletions
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 )) );
}
}