Kaydet (Commit) a3e725b8 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Replace uses of SAL_BOUND with o3tl::clamp

Change-Id: I66a7aad64623d778b4bf2fea591f227fdac2fdc7
Reviewed-on: https://gerrit.libreoffice.org/63264
Tested-by: Jenkins
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst b9b7f98b
......@@ -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 )) );
}
}
......
......@@ -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);
......
......@@ -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++)
......
......@@ -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))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment