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

Alpha channel in BitmapColor - change bIndex to alpha

We want to store the alpha channel in BitmapColor. To achieve this
we can repurpose bIndex attribute for alpha. Generally we don't
need bIndex at all as we can infer if we use index colors or not
from the context (using palette or not)

Change-Id: I18fe748beeca59e2869368a1c3c2ee9d2062b41e
Reviewed-on: https://gerrit.libreoffice.org/61057
Tested-by: Jenkins
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 2ddc6186
...@@ -69,6 +69,8 @@ public: ...@@ -69,6 +69,8 @@ public:
typedef vcl::ScopedBitmapAccess< BitmapReadAccess, AlphaMask, &AlphaMask::AcquireReadAccess > typedef vcl::ScopedBitmapAccess< BitmapReadAccess, AlphaMask, &AlphaMask::AcquireReadAccess >
ScopedReadAccess; ScopedReadAccess;
using Bitmap::IsEmpty;
private: private:
friend class BitmapEx; friend class BitmapEx;
friend class ::OutputDevice; friend class ::OutputDevice;
......
...@@ -94,20 +94,19 @@ private: ...@@ -94,20 +94,19 @@ private:
sal_uInt8 mcBlueOrIndex; sal_uInt8 mcBlueOrIndex;
sal_uInt8 mcGreen; sal_uInt8 mcGreen;
sal_uInt8 mcRed; sal_uInt8 mcRed;
bool mbIndex; sal_uInt8 mcAlpha;
public: public:
inline BitmapColor(); 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 ); inline BitmapColor( const Color& rColor );
explicit inline BitmapColor( sal_uInt8 cIndex ); explicit inline BitmapColor( sal_uInt8 cIndex );
inline bool operator==( const BitmapColor& rBitmapColor ) const; inline bool operator==( const BitmapColor& rBitmapColor ) const;
inline bool operator!=( const BitmapColor& rBitmapColor ) const; inline bool operator!=( const BitmapColor& rBitmapColor ) const;
inline bool IsIndex() const;
inline sal_uInt8 GetRed() const; inline sal_uInt8 GetRed() const;
inline void SetRed( sal_uInt8 cRed ); inline void SetRed( sal_uInt8 cRed );
...@@ -122,6 +121,9 @@ public: ...@@ -122,6 +121,9 @@ public:
Color GetColor() const; Color GetColor() const;
inline sal_uInt8 GetAlpha() const;
inline void SetAlpha( sal_uInt8 cAlpha );
inline sal_uInt8 GetBlueOrIndex() const; inline sal_uInt8 GetBlueOrIndex() const;
inline BitmapColor& Invert(); inline BitmapColor& Invert();
...@@ -137,7 +139,7 @@ template<typename charT, typename traits> ...@@ -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) 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: " 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; class Palette;
...@@ -350,18 +352,18 @@ VCL_DLLPUBLIC std::unique_ptr<BitmapBuffer> StretchAndConvert( ...@@ -350,18 +352,18 @@ VCL_DLLPUBLIC std::unique_ptr<BitmapBuffer> StretchAndConvert(
ScanlineFormat nDstBitmapFormat, const BitmapPalette* pDstPal = nullptr, const ColorMask* pDstMask = nullptr ); ScanlineFormat nDstBitmapFormat, const BitmapPalette* pDstPal = nullptr, const ColorMask* pDstMask = nullptr );
inline BitmapColor::BitmapColor() : inline BitmapColor::BitmapColor() :
mcBlueOrIndex ( 0 ), mcBlueOrIndex (0),
mcGreen ( 0 ), mcGreen (0),
mcRed ( 0 ), mcRed (0),
mbIndex (false) 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 ), mcBlueOrIndex ( cBlue ),
mcGreen ( cGreen ), mcGreen ( cGreen ),
mcRed ( cRed ), mcRed ( cRed ),
mbIndex (false) mcAlpha ( cAlpha )
{ {
} }
...@@ -369,7 +371,7 @@ inline BitmapColor::BitmapColor( const Color& rColor ) : ...@@ -369,7 +371,7 @@ inline BitmapColor::BitmapColor( const Color& rColor ) :
mcBlueOrIndex ( rColor.GetBlue() ), mcBlueOrIndex ( rColor.GetBlue() ),
mcGreen ( rColor.GetGreen() ), mcGreen ( rColor.GetGreen() ),
mcRed ( rColor.GetRed() ), mcRed ( rColor.GetRed() ),
mbIndex (false) mcAlpha ( rColor.GetTransparency() )
{ {
} }
...@@ -377,15 +379,16 @@ inline BitmapColor::BitmapColor( sal_uInt8 cIndex ) : ...@@ -377,15 +379,16 @@ inline BitmapColor::BitmapColor( sal_uInt8 cIndex ) :
mcBlueOrIndex ( cIndex ), mcBlueOrIndex ( cIndex ),
mcGreen ( 0 ), mcGreen ( 0 ),
mcRed ( 0 ), mcRed ( 0 ),
mbIndex (true) mcAlpha ( 0 )
{ {
} }
inline bool BitmapColor::operator==( const BitmapColor& rBitmapColor ) const inline bool BitmapColor::operator==( const BitmapColor& rBitmapColor ) const
{ {
return( ( mcBlueOrIndex == rBitmapColor.mcBlueOrIndex ) && return mcBlueOrIndex == rBitmapColor.mcBlueOrIndex &&
( mbIndex ? rBitmapColor.mbIndex : mcGreen == rBitmapColor.mcGreen &&
( mcGreen == rBitmapColor.mcGreen && mcRed == rBitmapColor.mcRed ) ) ); mcRed == rBitmapColor.mcRed &&
mcAlpha == rBitmapColor.mcAlpha;
} }
inline bool BitmapColor::operator!=( const BitmapColor& rBitmapColor ) const inline bool BitmapColor::operator!=( const BitmapColor& rBitmapColor ) const
...@@ -393,63 +396,59 @@ inline bool BitmapColor::operator!=( const BitmapColor& rBitmapColor ) const ...@@ -393,63 +396,59 @@ inline bool BitmapColor::operator!=( const BitmapColor& rBitmapColor ) const
return !( *this == rBitmapColor ); return !( *this == rBitmapColor );
} }
inline bool BitmapColor::IsIndex() const
{
return mbIndex;
}
inline sal_uInt8 BitmapColor::GetRed() const inline sal_uInt8 BitmapColor::GetRed() const
{ {
assert( !mbIndex && "Pixel represents index into colortable" );
return mcRed; return mcRed;
} }
inline void BitmapColor::SetRed( sal_uInt8 cRed ) inline void BitmapColor::SetRed( sal_uInt8 cRed )
{ {
assert( !mbIndex && "Pixel represents index into colortable" );
mcRed = cRed; mcRed = cRed;
} }
inline sal_uInt8 BitmapColor::GetGreen() const inline sal_uInt8 BitmapColor::GetGreen() const
{ {
assert( !mbIndex && "Pixel represents index into colortable" );
return mcGreen; return mcGreen;
} }
inline void BitmapColor::SetGreen( sal_uInt8 cGreen ) inline void BitmapColor::SetGreen( sal_uInt8 cGreen )
{ {
assert( !mbIndex && "Pixel represents index into colortable" );
mcGreen = cGreen; mcGreen = cGreen;
} }
inline sal_uInt8 BitmapColor::GetBlue() const inline sal_uInt8 BitmapColor::GetBlue() const
{ {
assert( !mbIndex && "Pixel represents index into colortable" );
return mcBlueOrIndex; return mcBlueOrIndex;
} }
inline void BitmapColor::SetBlue( sal_uInt8 cBlue ) inline void BitmapColor::SetBlue( sal_uInt8 cBlue )
{ {
assert( !mbIndex && "Pixel represents index into colortable" );
mcBlueOrIndex = cBlue; mcBlueOrIndex = cBlue;
} }
inline sal_uInt8 BitmapColor::GetIndex() const inline sal_uInt8 BitmapColor::GetIndex() const
{ {
assert( mbIndex && "Pixel represents color values" );
return mcBlueOrIndex; return mcBlueOrIndex;
} }
inline void BitmapColor::SetIndex( sal_uInt8 cIndex ) inline void BitmapColor::SetIndex( sal_uInt8 cIndex )
{ {
assert( mbIndex && "Pixel represents color values" );
mcBlueOrIndex = cIndex; mcBlueOrIndex = cIndex;
} }
inline Color BitmapColor::GetColor() const inline Color BitmapColor::GetColor() const
{ {
assert( !mbIndex && "Pixel represents index into colortable" ); return Color(mcAlpha, mcRed, mcGreen, mcBlueOrIndex);
return Color(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 inline sal_uInt8 BitmapColor::GetBlueOrIndex() const
...@@ -460,7 +459,6 @@ inline sal_uInt8 BitmapColor::GetBlueOrIndex() const ...@@ -460,7 +459,6 @@ inline sal_uInt8 BitmapColor::GetBlueOrIndex() const
inline BitmapColor& BitmapColor::Invert() inline BitmapColor& BitmapColor::Invert()
{ {
assert( !mbIndex && "Pixel represents index into colortable" );
mcBlueOrIndex = ~mcBlueOrIndex; mcBlueOrIndex = ~mcBlueOrIndex;
mcGreen = ~mcGreen; mcGreen = ~mcGreen;
mcRed = ~mcRed; mcRed = ~mcRed;
...@@ -470,7 +468,6 @@ inline BitmapColor& BitmapColor::Invert() ...@@ -470,7 +468,6 @@ inline BitmapColor& BitmapColor::Invert()
inline sal_uInt8 BitmapColor::GetLuminance() const inline sal_uInt8 BitmapColor::GetLuminance() const
{ {
assert( !mbIndex && "Pixel represents index into colortable" );
return (static_cast<sal_uInt32>(mcBlueOrIndex) * 28 return (static_cast<sal_uInt32>(mcBlueOrIndex) * 28
+ static_cast<sal_uInt32>(mcGreen) * 151 + static_cast<sal_uInt32>(mcGreen) * 151
+ static_cast<sal_uInt32>(mcRed) * 77) >> 8; + static_cast<sal_uInt32>(mcRed) * 77) >> 8;
...@@ -479,8 +476,6 @@ inline sal_uInt8 BitmapColor::GetLuminance() const ...@@ -479,8 +476,6 @@ inline sal_uInt8 BitmapColor::GetLuminance() const
inline BitmapColor& BitmapColor::Merge( const BitmapColor& rBitmapColor, sal_uInt8 cTransparency ) 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 ); mcBlueOrIndex = ColorChannelMerge( mcBlueOrIndex, rBitmapColor.mcBlueOrIndex, cTransparency );
mcGreen = ColorChannelMerge( mcGreen, rBitmapColor.mcGreen, cTransparency ); mcGreen = ColorChannelMerge( mcGreen, rBitmapColor.mcGreen, cTransparency );
mcRed = ColorChannelMerge( mcRed, rBitmapColor.mcRed, cTransparency ); mcRed = ColorChannelMerge( mcRed, rBitmapColor.mcRed, cTransparency );
...@@ -491,8 +486,6 @@ inline BitmapColor& BitmapColor::Merge( const BitmapColor& rBitmapColor, sal_uIn ...@@ -491,8 +486,6 @@ inline BitmapColor& BitmapColor::Merge( const BitmapColor& rBitmapColor, sal_uIn
inline sal_uInt16 BitmapColor::GetColorError( const BitmapColor& rBitmapColor ) const 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>( return static_cast<sal_uInt16>(
abs( static_cast<int>(mcBlueOrIndex) - static_cast<int>(rBitmapColor.mcBlueOrIndex) ) + abs( static_cast<int>(mcBlueOrIndex) - static_cast<int>(rBitmapColor.mcBlueOrIndex) ) +
abs( static_cast<int>(mcGreen) - static_cast<int>(rBitmapColor.mcGreen) ) + abs( static_cast<int>(mcGreen) - static_cast<int>(rBitmapColor.mcGreen) ) +
......
...@@ -35,9 +35,8 @@ public: ...@@ -35,9 +35,8 @@ public:
void defaultConstructor(); void defaultConstructor();
void colorValueConstructor(); void colorValueConstructor();
void colorClassConstructor(); void colorClassConstructor();
void getColor();
void setValue(); void setValue();
void invert(); void invert();
void getLuminance(); void getLuminance();
...@@ -45,6 +44,7 @@ public: ...@@ -45,6 +44,7 @@ public:
CPPUNIT_TEST(defaultConstructor); CPPUNIT_TEST(defaultConstructor);
CPPUNIT_TEST(colorValueConstructor); CPPUNIT_TEST(colorValueConstructor);
CPPUNIT_TEST(colorClassConstructor); CPPUNIT_TEST(colorClassConstructor);
CPPUNIT_TEST(getColor);
CPPUNIT_TEST(setValue); CPPUNIT_TEST(setValue);
CPPUNIT_TEST(invert); CPPUNIT_TEST(invert);
CPPUNIT_TEST(getLuminance); CPPUNIT_TEST(getLuminance);
...@@ -58,7 +58,7 @@ void BitmapColorTest::defaultConstructor() ...@@ -58,7 +58,7 @@ void BitmapColorTest::defaultConstructor()
CPPUNIT_ASSERT_EQUAL_MESSAGE("Red wrong", static_cast<sal_uInt8>(0), aBmpColor.GetRed()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Red wrong", static_cast<sal_uInt8>(0), aBmpColor.GetRed());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(0), aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(0), aBmpColor.GetGreen());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Index wrong", false, aBmpColor.IsIndex()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0), aBmpColor.GetAlpha());
} }
void BitmapColorTest::colorValueConstructor() void BitmapColorTest::colorValueConstructor()
...@@ -70,7 +70,8 @@ void BitmapColorTest::colorValueConstructor() ...@@ -70,7 +70,8 @@ void BitmapColorTest::colorValueConstructor()
CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(0), CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(0),
aBmpColor.GetGreen()); aBmpColor.GetGreen());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Index wrong", false, aBmpColor.IsIndex()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0),
aBmpColor.GetAlpha());
} }
{ {
...@@ -81,7 +82,8 @@ void BitmapColorTest::colorValueConstructor() ...@@ -81,7 +82,8 @@ void BitmapColorTest::colorValueConstructor()
aBmpColor.GetGreen()); aBmpColor.GetGreen());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(128), CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(128),
aBmpColor.GetBlue()); aBmpColor.GetBlue());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Index wrong", false, aBmpColor.IsIndex()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0),
aBmpColor.GetAlpha());
} }
{ {
...@@ -92,7 +94,8 @@ void BitmapColorTest::colorValueConstructor() ...@@ -92,7 +94,8 @@ void BitmapColorTest::colorValueConstructor()
aBmpColor.GetGreen()); aBmpColor.GetGreen());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(255), CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(255),
aBmpColor.GetBlue()); aBmpColor.GetBlue());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Index wrong", false, aBmpColor.IsIndex()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0),
aBmpColor.GetAlpha());
} }
} }
...@@ -106,7 +109,8 @@ void BitmapColorTest::colorClassConstructor() ...@@ -106,7 +109,8 @@ void BitmapColorTest::colorClassConstructor()
CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(0), CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(0),
aBmpColor.GetGreen()); aBmpColor.GetGreen());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Index wrong", false, aBmpColor.IsIndex()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0),
aBmpColor.GetAlpha());
} }
{ {
...@@ -118,7 +122,8 @@ void BitmapColorTest::colorClassConstructor() ...@@ -118,7 +122,8 @@ void BitmapColorTest::colorClassConstructor()
aBmpColor.GetGreen()); aBmpColor.GetGreen());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(127), CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(127),
aBmpColor.GetBlue()); aBmpColor.GetBlue());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Index wrong", false, aBmpColor.IsIndex()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0),
aBmpColor.GetAlpha());
} }
{ {
...@@ -130,10 +135,35 @@ void BitmapColorTest::colorClassConstructor() ...@@ -130,10 +135,35 @@ void BitmapColorTest::colorClassConstructor()
aBmpColor.GetGreen()); aBmpColor.GetGreen());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(255), CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(255),
aBmpColor.GetBlue()); aBmpColor.GetBlue());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Index wrong", false, aBmpColor.IsIndex()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0),
aBmpColor.GetAlpha());
}
// Transparency / Alpha
{
Color aColor(255, 128, 64, 0);
BitmapColor aBmpColor(aColor);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Red wrong", static_cast<sal_uInt8>(128), aBmpColor.GetRed());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(64),
aBmpColor.GetGreen());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(255),
aBmpColor.GetAlpha());
} }
} }
void BitmapColorTest::getColor()
{
BitmapColor aBitmapColor(255, 128, 64, 32);
Color aColor = aBitmapColor.GetColor();
CPPUNIT_ASSERT_EQUAL_MESSAGE("Red wrong", sal_uInt8(255), aColor.GetRed());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", sal_uInt8(128), aColor.GetGreen());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", sal_uInt8(64), aColor.GetBlue());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparecy wrong", sal_uInt8(32), aColor.GetTransparency());
}
void BitmapColorTest::setValue() void BitmapColorTest::setValue()
{ {
BitmapColor aBmpColor; BitmapColor aBmpColor;
......
...@@ -652,18 +652,7 @@ css::uno::Sequence< sal_Int8 > GetMaskDIB(BitmapEx const & aBmpEx) ...@@ -652,18 +652,7 @@ css::uno::Sequence< sal_Int8 > GetMaskDIB(BitmapEx const & aBmpEx)
static sal_uInt8 lcl_GetColor(BitmapColor const& rColor) static sal_uInt8 lcl_GetColor(BitmapColor const& rColor)
{ {
sal_uInt8 nTemp(0); return rColor.GetBlueOrIndex();
if (rColor.IsIndex())
{
nTemp = rColor.GetIndex();
}
else
{
nTemp = rColor.GetBlue();
// greyscale expected here, or what would non-grey colors mean?
assert(rColor.GetRed() == nTemp && rColor.GetGreen() == nTemp);
}
return nTemp;
} }
......
...@@ -79,11 +79,7 @@ BitmapColor BitmapReadAccess::GetPixelForN8BitPal(ConstScanline pScanline, long ...@@ -79,11 +79,7 @@ BitmapColor BitmapReadAccess::GetPixelForN8BitPal(ConstScanline pScanline, long
void BitmapReadAccess::SetPixelForN8BitPal(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&) void BitmapReadAccess::SetPixelForN8BitPal(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
{ {
if (rBitmapColor.IsIndex()) pScanline[ nX ] = rBitmapColor.GetBlueOrIndex();
pScanline[ nX ] = rBitmapColor.GetIndex();
else
// Let's hope that the RGB color values equal, so it doesn't matter what do we pick
pScanline[ nX ] = rBitmapColor.GetBlueOrIndex();
} }
BitmapColor BitmapReadAccess::GetPixelForN8BitTcMask(ConstScanline pScanline, long nX, const ColorMask& rMask) BitmapColor BitmapReadAccess::GetPixelForN8BitTcMask(ConstScanline pScanline, long nX, const ColorMask& rMask)
......
...@@ -192,7 +192,7 @@ SalPrinterBmp::GetPixelRGB (sal_uInt32 nRow, sal_uInt32 nColumn) const ...@@ -192,7 +192,7 @@ SalPrinterBmp::GetPixelRGB (sal_uInt32 nRow, sal_uInt32 nColumn) const
Scanline pScan = mpScanAccess + nRow * mnScanOffset; Scanline pScan = mpScanAccess + nRow * mnScanOffset;
BitmapColor aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask); BitmapColor aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask);
if (aColor.IsIndex()) if (!!mpBmpBuffer->maPalette)
GetPaletteColor(aColor.GetIndex()); GetPaletteColor(aColor.GetIndex());
return ((aColor.GetBlue()) & 0x000000ff) return ((aColor.GetBlue()) & 0x000000ff)
...@@ -206,7 +206,7 @@ SalPrinterBmp::GetPixelGray (sal_uInt32 nRow, sal_uInt32 nColumn) const ...@@ -206,7 +206,7 @@ SalPrinterBmp::GetPixelGray (sal_uInt32 nRow, sal_uInt32 nColumn) const
Scanline pScan = mpScanAccess + nRow * mnScanOffset; Scanline pScan = mpScanAccess + nRow * mnScanOffset;
BitmapColor aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask); BitmapColor aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask);
if (aColor.IsIndex()) if (!!mpBmpBuffer->maPalette)
aColor = mpBmpBuffer->maPalette[aColor.GetIndex()]; aColor = mpBmpBuffer->maPalette[aColor.GetIndex()];
return ( aColor.GetBlue() * 28UL return ( aColor.GetBlue() * 28UL
...@@ -221,7 +221,7 @@ SalPrinterBmp::GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const ...@@ -221,7 +221,7 @@ SalPrinterBmp::GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const
Scanline pScan = mpScanAccess + nRow * mnScanOffset; Scanline pScan = mpScanAccess + nRow * mnScanOffset;
BitmapColor aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask); BitmapColor aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask);
if (aColor.IsIndex()) if (!!mpBmpBuffer->maPalette)
return aColor.GetIndex(); return aColor.GetIndex();
else else
return 0; return 0;
......
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