Kaydet (Commit) d370b676 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

cleanup and rename COLORDATA_RGB to color::extractRGB

Change-Id: I8d53c7010b4fea2a74e48f0649e944a498c211c7
Reviewed-on: https://gerrit.libreoffice.org/71003
Tested-by: Jenkins
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 60de1cb0
......@@ -26,7 +26,15 @@
class SvStream;
constexpr sal_uInt32 COLORDATA_RGB( sal_uInt32 n ) { return static_cast<sal_uInt32>(n & 0x00FFFFFF); }
namespace color
{
constexpr sal_uInt32 extractRGB(sal_uInt32 nColorNumber)
{
return nColorNumber & 0x00FFFFFF;
}
}
// Color
......@@ -115,7 +123,7 @@ public:
Color GetRGBColor() const
{
return COLORDATA_RGB(mValue);
return color::extractRGB(mValue);
}
sal_uInt8 GetColorError(const Color& rCompareColor) const;
......@@ -202,7 +210,7 @@ inline void Color::SetTransparency( sal_uInt8 nTransparency )
inline bool Color::IsRGBEqual( const Color& rColor ) const
{
return COLORDATA_RGB(mValue) == COLORDATA_RGB(rColor.mValue);
return color::extractRGB(mValue) == color::extractRGB(rColor.mValue);
}
inline sal_uInt8 Color::GetLuminance() const
......@@ -212,8 +220,8 @@ inline sal_uInt8 Color::GetLuminance() const
constexpr sal_uInt8 ColorChannelMerge(sal_uInt8 nDst, sal_uInt8 nSrc, sal_uInt8 nSrcTrans)
{
return static_cast<sal_uInt8>(((static_cast<sal_Int32>(nDst)-nSrc)*nSrcTrans+((nSrc<<8)|nDst))>>8);
};
return sal_uInt8(((sal_Int32(nDst) - nSrc) * nSrcTrans + ((nSrc << 8) | nDst)) >> 8);
}
inline void Color::Merge( const Color& rMergeColor, sal_uInt8 cTransparency )
{
......
......@@ -35,7 +35,7 @@ sal_uInt8 Color::GetColorError( const Color& rCompareColor ) const
labs(long(rCompareColor.G) - G) +
labs(long(rCompareColor.B) - B);
return static_cast<sal_uInt8>(FRound( nErrAbs * 0.3333333333 ));
return sal_uInt8(FRound(double(nErrAbs) / 3.0));
}
void Color::IncreaseLuminance(sal_uInt8 cLumInc)
......@@ -52,11 +52,11 @@ void Color::DecreaseLuminance(sal_uInt8 cLumDec)
B = sal_uInt8(std::clamp(long(B) - cLumDec, 0L, 255L));
}
void Color::DecreaseContrast( sal_uInt8 cContDec )
void Color::DecreaseContrast(sal_uInt8 nContDec)
{
if( cContDec )
if (nContDec)
{
const double fM = ( 128.0 - 0.4985 * cContDec ) / 128.0;
const double fM = (128.0 - 0.4985 * nContDec) / 128.0;
const double fOff = 128.0 - fM * 128.0;
R = sal_uInt8(std::clamp(FRound(R * fM + fOff), 0L, 255L));
......
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