summaryrefslogtreecommitdiff
path: root/include/vcl/salbtype.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'include/vcl/salbtype.hxx')
-rw-r--r--include/vcl/salbtype.hxx67
1 files changed, 30 insertions, 37 deletions
diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx
index b965fa333c08..ac2f283e7172 100644
--- a/include/vcl/salbtype.hxx
+++ b/include/vcl/salbtype.hxx
@@ -94,20 +94,19 @@ private:
sal_uInt8 mcBlueOrIndex;
sal_uInt8 mcGreen;
sal_uInt8 mcRed;
- bool mbIndex;
+ sal_uInt8 mcAlpha;
public:
inline BitmapColor();
- constexpr BitmapColor( sal_uInt8 cRed, sal_uInt8 cGreen, sal_uInt8 cBlue );
+ constexpr BitmapColor( sal_uInt8 cRed, sal_uInt8 cGreen, sal_uInt8 cBlue, sal_uInt8 cAlpha = 0 );
+
inline BitmapColor( const Color& rColor );
explicit inline BitmapColor( sal_uInt8 cIndex );
inline bool operator==( const BitmapColor& rBitmapColor ) const;
inline bool operator!=( const BitmapColor& rBitmapColor ) const;
- inline bool IsIndex() const;
-
inline sal_uInt8 GetRed() const;
inline void SetRed( sal_uInt8 cRed );
@@ -122,6 +121,9 @@ public:
Color GetColor() const;
+ inline sal_uInt8 GetAlpha() const;
+ inline void SetAlpha( sal_uInt8 cAlpha );
+
inline sal_uInt8 GetBlueOrIndex() const;
inline BitmapColor& Invert();
@@ -137,7 +139,7 @@ template<typename charT, typename traits>
inline std::basic_ostream<charT, traits>& operator <<(std::basic_ostream<charT, traits>& rStream, const BitmapColor& rColor)
{
return rStream << "mcBlueOrIndex: " << static_cast<int>(rColor.GetBlueOrIndex()) << ", mcGreen: "
- << static_cast<int>(rColor.GetGreen()) << ", mcRed: " << static_cast<int>(rColor.GetRed()) << ", mbIndex: " << static_cast<int>(rColor.IsIndex());
+ << static_cast<int>(rColor.GetGreen()) << ", mcRed: " << static_cast<int>(rColor.GetRed()) << ", mcAlpha: " << static_cast<int>(rColor.GetAlpha());
}
class Palette;
@@ -350,18 +352,18 @@ VCL_DLLPUBLIC std::unique_ptr<BitmapBuffer> StretchAndConvert(
ScanlineFormat nDstBitmapFormat, const BitmapPalette* pDstPal = nullptr, const ColorMask* pDstMask = nullptr );
inline BitmapColor::BitmapColor() :
- mcBlueOrIndex ( 0 ),
- mcGreen ( 0 ),
- mcRed ( 0 ),
- mbIndex (false)
+ mcBlueOrIndex (0),
+ mcGreen (0),
+ mcRed (0),
+ mcAlpha (0)
{
}
-constexpr BitmapColor::BitmapColor( sal_uInt8 cRed, sal_uInt8 cGreen, sal_uInt8 cBlue ) :
+constexpr BitmapColor::BitmapColor(sal_uInt8 cRed, sal_uInt8 cGreen, sal_uInt8 cBlue, sal_uInt8 cAlpha) :
mcBlueOrIndex ( cBlue ),
mcGreen ( cGreen ),
mcRed ( cRed ),
- mbIndex (false)
+ mcAlpha ( cAlpha )
{
}
@@ -369,7 +371,7 @@ inline BitmapColor::BitmapColor( const Color& rColor ) :
mcBlueOrIndex ( rColor.GetBlue() ),
mcGreen ( rColor.GetGreen() ),
mcRed ( rColor.GetRed() ),
- mbIndex (false)
+ mcAlpha ( rColor.GetTransparency() )
{
}
@@ -377,15 +379,16 @@ inline BitmapColor::BitmapColor( sal_uInt8 cIndex ) :
mcBlueOrIndex ( cIndex ),
mcGreen ( 0 ),
mcRed ( 0 ),
- mbIndex (true)
+ mcAlpha ( 0 )
{
}
inline bool BitmapColor::operator==( const BitmapColor& rBitmapColor ) const
{
- return( ( mcBlueOrIndex == rBitmapColor.mcBlueOrIndex ) &&
- ( mbIndex ? rBitmapColor.mbIndex :
- ( mcGreen == rBitmapColor.mcGreen && mcRed == rBitmapColor.mcRed ) ) );
+ return mcBlueOrIndex == rBitmapColor.mcBlueOrIndex &&
+ mcGreen == rBitmapColor.mcGreen &&
+ mcRed == rBitmapColor.mcRed &&
+ mcAlpha == rBitmapColor.mcAlpha;
}
inline bool BitmapColor::operator!=( const BitmapColor& rBitmapColor ) const
@@ -393,63 +396,59 @@ inline bool BitmapColor::operator!=( const BitmapColor& rBitmapColor ) const
return !( *this == rBitmapColor );
}
-inline bool BitmapColor::IsIndex() const
-{
- return mbIndex;
-}
-
inline sal_uInt8 BitmapColor::GetRed() const
{
- assert( !mbIndex && "Pixel represents index into colortable" );
return mcRed;
}
inline void BitmapColor::SetRed( sal_uInt8 cRed )
{
- assert( !mbIndex && "Pixel represents index into colortable" );
mcRed = cRed;
}
inline sal_uInt8 BitmapColor::GetGreen() const
{
- assert( !mbIndex && "Pixel represents index into colortable" );
return mcGreen;
}
inline void BitmapColor::SetGreen( sal_uInt8 cGreen )
{
- assert( !mbIndex && "Pixel represents index into colortable" );
mcGreen = cGreen;
}
inline sal_uInt8 BitmapColor::GetBlue() const
{
- assert( !mbIndex && "Pixel represents index into colortable" );
return mcBlueOrIndex;
}
inline void BitmapColor::SetBlue( sal_uInt8 cBlue )
{
- assert( !mbIndex && "Pixel represents index into colortable" );
mcBlueOrIndex = cBlue;
}
inline sal_uInt8 BitmapColor::GetIndex() const
{
- assert( mbIndex && "Pixel represents color values" );
return mcBlueOrIndex;
}
inline void BitmapColor::SetIndex( sal_uInt8 cIndex )
{
- assert( mbIndex && "Pixel represents color values" );
mcBlueOrIndex = cIndex;
}
inline Color BitmapColor::GetColor() const
{
- assert( !mbIndex && "Pixel represents index into colortable" );
- return Color(mcRed, mcGreen, mcBlueOrIndex);
+ return Color(mcAlpha, mcRed, mcGreen, mcBlueOrIndex);
+}
+
+inline sal_uInt8 BitmapColor::GetAlpha() const
+{
+ return mcAlpha;
+}
+
+inline void BitmapColor::SetAlpha( sal_uInt8 cAlpha )
+{
+ mcAlpha = cAlpha;
}
inline sal_uInt8 BitmapColor::GetBlueOrIndex() const
@@ -460,7 +459,6 @@ inline sal_uInt8 BitmapColor::GetBlueOrIndex() const
inline BitmapColor& BitmapColor::Invert()
{
- assert( !mbIndex && "Pixel represents index into colortable" );
mcBlueOrIndex = ~mcBlueOrIndex;
mcGreen = ~mcGreen;
mcRed = ~mcRed;
@@ -470,7 +468,6 @@ inline BitmapColor& BitmapColor::Invert()
inline sal_uInt8 BitmapColor::GetLuminance() const
{
- assert( !mbIndex && "Pixel represents index into colortable" );
return (static_cast<sal_uInt32>(mcBlueOrIndex) * 28
+ static_cast<sal_uInt32>(mcGreen) * 151
+ static_cast<sal_uInt32>(mcRed) * 77) >> 8;
@@ -479,8 +476,6 @@ inline sal_uInt8 BitmapColor::GetLuminance() const
inline BitmapColor& BitmapColor::Merge( const BitmapColor& rBitmapColor, sal_uInt8 cTransparency )
{
- assert( !mbIndex && "Pixel represents index into colortable" );
- assert( !rBitmapColor.mbIndex && "Pixel represents index into colortable" );
mcBlueOrIndex = ColorChannelMerge( mcBlueOrIndex, rBitmapColor.mcBlueOrIndex, cTransparency );
mcGreen = ColorChannelMerge( mcGreen, rBitmapColor.mcGreen, cTransparency );
mcRed = ColorChannelMerge( mcRed, rBitmapColor.mcRed, cTransparency );
@@ -491,8 +486,6 @@ inline BitmapColor& BitmapColor::Merge( const BitmapColor& rBitmapColor, sal_uIn
inline sal_uInt16 BitmapColor::GetColorError( const BitmapColor& rBitmapColor ) const
{
- assert( !mbIndex && "Pixel represents index into colortable" );
- assert( !rBitmapColor.mbIndex && "Pixel represents index into colortable" );
return static_cast<sal_uInt16>(
abs( static_cast<int>(mcBlueOrIndex) - static_cast<int>(rBitmapColor.mcBlueOrIndex) ) +
abs( static_cast<int>(mcGreen) - static_cast<int>(rBitmapColor.mcGreen) ) +