summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2021-02-27 15:50:37 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-04-26 12:51:58 +0200
commitddd2639a482befb4a3bf1f75a88e66c21a691b67 (patch)
tree2d2a2a0695dce2b8b065f107368ef0412807fa73 /vcl
parent9c4e0c35d70659097b235028047efcb80dcfb10d (diff)
drop mask from BitmapEx
So that we have fewer cases to deal with when we transition to 32-bit bitmaps. (*) rename maMask to maAlphaMask, since now it is only being used for alpha duties. (*) drop mbAlpha and mbTransparent to simplify state management, the only thing we need to check for alpha is if maAlphaMask is non-empty. Change-Id: I06252e38e950e846a94b4c2ba8ea763be17801fe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111679 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/osx/salinst.cxx13
-rw-r--r--vcl/qa/cppunit/canvasbitmaptest.cxx20
-rw-r--r--vcl/source/animate/Animation.cxx2
-rw-r--r--vcl/source/bitmap/BitmapAlphaClampFilter.cxx2
-rw-r--r--vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx2
-rw-r--r--vcl/source/bitmap/BitmapDisabledImageFilter.cxx2
-rw-r--r--vcl/source/bitmap/BitmapEx.cxx314
-rw-r--r--vcl/source/bitmap/BitmapFastScaleFilter.cxx4
-rw-r--r--vcl/source/bitmap/BitmapFilterStackBlur.cxx2
-rw-r--r--vcl/source/bitmap/BitmapTools.cxx121
-rw-r--r--vcl/source/bitmap/bitmapfilter.cxx2
-rw-r--r--vcl/source/bitmap/dibtools.cxx8
-rw-r--r--vcl/source/control/ivctrl.cxx2
-rw-r--r--vcl/source/filter/egif/egif.cxx2
-rw-r--r--vcl/source/filter/eps/eps.cxx10
-rw-r--r--vcl/source/filter/graphicfilter.cxx2
-rw-r--r--vcl/source/filter/png/pngwrite.cxx86
-rw-r--r--vcl/source/filter/wmf/emfwr.cxx6
-rw-r--r--vcl/source/filter/wmf/wmfwr.cxx6
-rw-r--r--vcl/source/gdi/gdimetafiletools.cxx2
-rw-r--r--vcl/source/gdi/gdimtf.cxx2
-rw-r--r--vcl/source/gdi/impgraph.cxx4
-rw-r--r--vcl/source/gdi/mtfxmldump.cxx20
-rw-r--r--vcl/source/gdi/pdfextoutdevdata.cxx7
-rw-r--r--vcl/source/gdi/pdfwriter.cxx4
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx52
-rw-r--r--vcl/source/gdi/pdfwriter_impl.hxx4
-rw-r--r--vcl/source/gdi/pdfwriter_impl2.cxx21
-rw-r--r--vcl/source/gdi/print.cxx5
-rw-r--r--vcl/source/gdi/print2.cxx32
-rw-r--r--vcl/source/graphic/GraphicID.cxx4
-rw-r--r--vcl/source/graphic/GraphicObject2.cxx11
-rw-r--r--vcl/source/graphic/UnoGraphic.cxx2
-rw-r--r--vcl/source/graphic/UnoGraphicTransformer.cxx19
-rw-r--r--vcl/source/helper/canvasbitmap.cxx28
-rw-r--r--vcl/source/image/Image.cxx2
-rw-r--r--vcl/source/outdev/bitmap.cxx29
-rw-r--r--vcl/source/outdev/outdevstate.cxx12
-rw-r--r--vcl/source/outdev/wallpaper.cxx4
-rw-r--r--vcl/unx/generic/window/salframe.cxx18
-rw-r--r--vcl/workben/vcldemo.cxx4
41 files changed, 257 insertions, 635 deletions
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index 85651e2079e9..75aea4d5415a 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -911,9 +911,9 @@ CGImageRef CreateCGImage( const Image& rImage )
return nullptr;
CGImageRef xImage = nullptr;
- if( ! (aBmpEx.IsAlpha() || aBmpEx.IsTransparent() ) )
+ if( !aBmpEx.IsAlpha() )
xImage = pSalBmp->CreateCroppedImage( 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight );
- else if( aBmpEx.IsAlpha() )
+ else
{
AlphaMask aAlphaMask( aBmpEx.GetAlpha() );
Bitmap aMask( aAlphaMask.GetBitmap() );
@@ -923,15 +923,6 @@ CGImageRef CreateCGImage( const Image& rImage )
else
xImage = pSalBmp->CreateCroppedImage( 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight );
}
- else if( aBmpEx.GetTransparentType() == TransparentType::Bitmap )
- {
- Bitmap aMask( aBmpEx.GetMask() );
- QuartzSalBitmap* pMaskBmp = static_cast<QuartzSalBitmap*>(aMask.ImplGetSalBitmap().get());
- if( pMaskBmp )
- xImage = pSalBmp->CreateWithMask( *pMaskBmp, 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight );
- else
- xImage = pSalBmp->CreateCroppedImage( 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight );
- }
return xImage;
}
diff --git a/vcl/qa/cppunit/canvasbitmaptest.cxx b/vcl/qa/cppunit/canvasbitmaptest.cxx
index a1185ab1f7ad..d77599e7b8a4 100644
--- a/vcl/qa/cppunit/canvasbitmaptest.cxx
+++ b/vcl/qa/cppunit/canvasbitmaptest.cxx
@@ -102,7 +102,7 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp,
sal_Int32(200), xBmp->getSize().Height);
CPPUNIT_ASSERT_EQUAL_MESSAGE( "alpha state mismatch",
- aContainedBmpEx.IsTransparent(), bool(xBmp->hasAlpha()));
+ aContainedBmpEx.IsAlpha(), bool(xBmp->hasAlpha()));
CPPUNIT_ASSERT_MESSAGE( "getScaledBitmap() failed",
xBmp->getScaledBitmap( geometry::RealSize2D(500,500), false ).is());
@@ -111,7 +111,7 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp,
uno::Sequence<sal_Int8> aPixelData = xBmp->getData(aLayout, geometry::IntegerRectangle2D(0,0,1,1));
const sal_Int32 nExpectedBitsPerPixel(
- (aContainedBmpEx.IsTransparent() ? std::max(8,nDepth)+8 : nDepth) + extraBpp);
+ (aContainedBmpEx.IsAlpha() ? std::max(8,nDepth)+8 : nDepth) + extraBpp);
CPPUNIT_ASSERT_EQUAL_MESSAGE( "# scanlines not 1",
static_cast<sal_Int32>(1), aLayout.ScanLines);
CPPUNIT_ASSERT_EQUAL_MESSAGE( "# scanline bytes mismatch",
@@ -164,7 +164,7 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp,
"First pixel is not white", 1.0, pRGBStart[0].Blue, 1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
"Second pixel is not opaque", 1.0, pARGBStart[1].Alpha, 1E-12);
- if( aContainedBmpEx.IsTransparent() )
+ if( aContainedBmpEx.IsAlpha() )
{
CPPUNIT_ASSERT_EQUAL_MESSAGE( "First pixel is not fully transparent",
0.0, pARGBStart[0].Alpha);
@@ -235,7 +235,7 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp,
CPPUNIT_ASSERT_MESSAGE( "Green pixel from bitmap mismatch with manually converted green pixel",
bool(aPixel3 == aPixel4));
- if( !aContainedBmpEx.IsTransparent() )
+ if( !aContainedBmpEx.IsAlpha() )
{
aPixel3 = xBmp->convertIntegerFromRGB( aRGBColor );
CPPUNIT_ASSERT_MESSAGE( "Green pixel from bitmap mismatch with manually RGB-converted green pixel",
@@ -675,7 +675,7 @@ void CanvasBitmapTest::runTest()
checkCanvasBitmap( xBmp, "single bitmap", nDepth );
- Bitmap aMask(Size(200,200), vcl::PixelFormat::N1_BPP);
+ Bitmap aMask(Size(200,200), vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256));
aMask.Erase(COL_WHITE);
{
BitmapScopedWriteAccess pAcc(aMask);
@@ -683,9 +683,9 @@ void CanvasBitmapTest::runTest()
{
pAcc->SetFillColor(COL_BLACK);
pAcc->FillRect(tools::Rectangle(0,0,100,100));
- pAcc->SetPixel(0,0,BitmapColor(1));
+ pAcc->SetPixel(0,0,BitmapColor(255));
pAcc->SetPixel(0,1,BitmapColor(0));
- pAcc->SetPixel(0,2,BitmapColor(1));
+ pAcc->SetPixel(0,2,BitmapColor(255));
}
}
@@ -719,8 +719,8 @@ void CanvasBitmapTest::runTest()
new TestBitmap( geometry::IntegerSize2D(10,10), true ));
BitmapEx aBmp = vcl::unotools::bitmapExFromXBitmap(xTestBmp);
- CPPUNIT_ASSERT_MESSAGE( "Palette bitmap is transparent",
- !aBmp.IsTransparent());
+ CPPUNIT_ASSERT_MESSAGE( "Palette bitmap is alpha",
+ !aBmp.IsAlpha());
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bitmap does not have size (10,10)",
Size(10,10), aBmp.GetSizePixel());
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bitmap does not have the expected pixel format",
@@ -745,8 +745,6 @@ void CanvasBitmapTest::runTest()
xTestBmp.set( new TestBitmap( geometry::IntegerSize2D(10,10), false ));
aBmp = vcl::unotools::bitmapExFromXBitmap(xTestBmp);
- CPPUNIT_ASSERT_MESSAGE( "Palette bitmap is not transparent",
- aBmp.IsTransparent());
CPPUNIT_ASSERT_MESSAGE( "Palette bitmap has no alpha",
aBmp.IsAlpha());
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bitmap does not have size (10,10)",
diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx
index 37c9f16afa26..e17592696195 100644
--- a/vcl/source/animate/Animation.cxx
+++ b/vcl/source/animate/Animation.cxx
@@ -113,7 +113,7 @@ bool Animation::IsTransparent() const
// as the application (?) does not invalidate on non-transparent
// graphics due to performance reasons.
- return maBitmapEx.IsTransparent()
+ return maBitmapEx.IsAlpha()
|| std::any_of(maList.begin(), maList.end(),
[&aRect](const std::unique_ptr<AnimationBitmap>& pAnim) -> bool {
return pAnim->meDisposal == Disposal::Back
diff --git a/vcl/source/bitmap/BitmapAlphaClampFilter.cxx b/vcl/source/bitmap/BitmapAlphaClampFilter.cxx
index d9bc79ad92b6..245d925a9766 100644
--- a/vcl/source/bitmap/BitmapAlphaClampFilter.cxx
+++ b/vcl/source/bitmap/BitmapAlphaClampFilter.cxx
@@ -15,7 +15,7 @@
BitmapEx BitmapAlphaClampFilter::execute(BitmapEx const& rBitmapEx) const
{
- if (!rBitmapEx.IsTransparent())
+ if (!rBitmapEx.IsAlpha())
return rBitmapEx;
AlphaMask aBitmapAlpha(rBitmapEx.GetAlpha());
diff --git a/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx b/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx
index 8bc038b486f9..3cd0bb87e4eb 100644
--- a/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx
+++ b/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx
@@ -333,7 +333,7 @@ BitmapBasicMorphologyFilter::~BitmapBasicMorphologyFilter() = default;
BitmapEx BitmapBasicMorphologyFilter::execute(BitmapEx const& rBitmapEx) const
{
Bitmap result = filter(rBitmapEx.GetBitmap());
- return BitmapEx(result, rBitmapEx.GetMask());
+ return BitmapEx(result, rBitmapEx.GetAlpha());
}
Bitmap BitmapBasicMorphologyFilter::filter(Bitmap const& rBitmap) const
diff --git a/vcl/source/bitmap/BitmapDisabledImageFilter.cxx b/vcl/source/bitmap/BitmapDisabledImageFilter.cxx
index e258d897ab1f..7a702effa0c3 100644
--- a/vcl/source/bitmap/BitmapDisabledImageFilter.cxx
+++ b/vcl/source/bitmap/BitmapDisabledImageFilter.cxx
@@ -47,7 +47,7 @@ BitmapEx BitmapDisabledImageFilter::execute(BitmapEx const& rBitmapEx) const
}
}
- if (rBitmapEx.IsTransparent())
+ if (rBitmapEx.IsAlpha())
{
aReturnBitmap = BitmapEx(aGrey, rBitmapEx.GetAlpha());
}
diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx
index bcf8480163cc..8d931d324b08 100644
--- a/vcl/source/bitmap/BitmapEx.cxx
+++ b/vcl/source/bitmap/BitmapEx.cxx
@@ -49,16 +49,12 @@
using namespace ::com::sun::star;
BitmapEx::BitmapEx()
- : meTransparent(TransparentType::NONE)
- , mbAlpha(false)
{
}
BitmapEx::BitmapEx( const BitmapEx& ) = default;
BitmapEx::BitmapEx( const BitmapEx& rBitmapEx, Point aSrc, Size aSize )
- : meTransparent(TransparentType::NONE)
- , mbAlpha(false)
{
if( rBitmapEx.IsEmpty() || aSize.IsEmpty() )
return;
@@ -66,12 +62,7 @@ BitmapEx::BitmapEx( const BitmapEx& rBitmapEx, Point aSrc, Size aSize )
maBitmap = Bitmap(aSize, rBitmapEx.maBitmap.getPixelFormat());
SetSizePixel(aSize);
if( rBitmapEx.IsAlpha() )
- {
- mbAlpha = true;
- maMask = AlphaMask( aSize ).ImplGetBitmap();
- }
- else if( rBitmapEx.IsTransparent() )
- maMask = Bitmap(aSize, rBitmapEx.maMask.getPixelFormat());
+ maAlphaMask = AlphaMask( aSize ).ImplGetBitmap();
tools::Rectangle aDestRect( Point( 0, 0 ), aSize );
tools::Rectangle aSrcRect( aSrc, aSize );
@@ -79,16 +70,12 @@ BitmapEx::BitmapEx( const BitmapEx& rBitmapEx, Point aSrc, Size aSize )
}
BitmapEx::BitmapEx(Size aSize, vcl::PixelFormat ePixelFormat)
- : meTransparent(TransparentType::NONE)
- , mbAlpha(false)
{
maBitmap = Bitmap(aSize, ePixelFormat);
SetSizePixel(aSize);
}
BitmapEx::BitmapEx( const OUString& rIconName )
- : meTransparent(TransparentType::NONE)
- , mbAlpha(false)
{
loadFromIconTheme( rIconName );
}
@@ -113,30 +100,25 @@ void BitmapEx::loadFromIconTheme( const OUString& rIconName )
BitmapEx::BitmapEx( const Bitmap& rBmp ) :
maBitmap ( rBmp ),
- maBitmapSize ( maBitmap.GetSizePixel() ),
- meTransparent( TransparentType::NONE ),
- mbAlpha ( false )
+ maBitmapSize ( maBitmap.GetSizePixel() )
{
}
BitmapEx::BitmapEx( const Bitmap& rBmp, const Bitmap& rMask ) :
maBitmap ( rBmp ),
- maMask ( rMask ),
- maBitmapSize ( maBitmap.GetSizePixel() ),
- meTransparent ( rMask.IsEmpty() ? TransparentType::NONE : TransparentType::Bitmap ),
- mbAlpha ( !rMask.IsEmpty() )
+ maBitmapSize ( maBitmap.GetSizePixel() )
{
if (rMask.IsEmpty())
return;
- if( maMask.getPixelFormat() == vcl::PixelFormat::N8_BPP && maMask.HasGreyPalette8Bit() )
- maMask = rMask;
- else if (maMask.getPixelFormat() == vcl::PixelFormat::N1_BPP)
+ if( rMask.getPixelFormat() == vcl::PixelFormat::N8_BPP && rMask.HasGreyPalette8Bit() )
+ maAlphaMask = rMask;
+ else if (rMask.getPixelFormat() == vcl::PixelFormat::N1_BPP)
{
// convert 1-bit mask to alpha bitmap
BitmapEx aBmpEx(rMask);
BitmapFilter::Filter(aBmpEx, BitmapMaskToAlphaFilter());
- maMask = aBmpEx.GetBitmap();
+ maAlphaMask = aBmpEx.GetBitmap();
}
else
{
@@ -145,40 +127,36 @@ BitmapEx::BitmapEx( const Bitmap& rBmp, const Bitmap& rMask ) :
BitmapEx aMaskEx(rMask);
BitmapFilter::Filter(aMaskEx, BitmapMonochromeFilter(255));
BitmapFilter::Filter(aMaskEx, BitmapMaskToAlphaFilter());
- maMask = aMaskEx.GetBitmap();
+ maAlphaMask = aMaskEx.GetBitmap();
}
- if (!maBitmap.IsEmpty() && maBitmap.GetSizePixel() != maMask.GetSizePixel())
+ if (!maBitmap.IsEmpty() && maBitmap.GetSizePixel() != maAlphaMask.GetSizePixel())
{
OSL_ENSURE(false, "Mask size differs from Bitmap size, corrected Mask (!)");
- maMask.Scale(maBitmap.GetSizePixel());
+ maAlphaMask.Scale(maBitmap.GetSizePixel());
}
}
BitmapEx::BitmapEx( const Bitmap& rBmp, const AlphaMask& rAlphaMask ) :
maBitmap ( rBmp ),
- maMask ( rAlphaMask.ImplGetBitmap() ),
- maBitmapSize ( maBitmap.GetSizePixel() ),
- meTransparent ( rAlphaMask.IsEmpty() ? TransparentType::NONE : TransparentType::Bitmap ),
- mbAlpha ( !rAlphaMask.IsEmpty() )
+ maAlphaMask ( rAlphaMask.ImplGetBitmap() ),
+ maBitmapSize ( maBitmap.GetSizePixel() )
{
- if (!maBitmap.IsEmpty() && !maMask.IsEmpty() && maBitmap.GetSizePixel() != maMask.GetSizePixel())
+ if (!maBitmap.IsEmpty() && !maAlphaMask.IsEmpty() && maBitmap.GetSizePixel() != maAlphaMask.GetSizePixel())
{
OSL_ENSURE(false, "Alpha size differs from Bitmap size, corrected Mask (!)");
- maMask.Scale(rBmp.GetSizePixel());
+ maAlphaMask.Scale(rBmp.GetSizePixel());
}
}
BitmapEx::BitmapEx( const Bitmap& rBmp, const Color& rTransparentColor ) :
maBitmap ( rBmp ),
- maBitmapSize ( maBitmap.GetSizePixel() ),
- meTransparent ( TransparentType::Bitmap ),
- mbAlpha ( false )
+ maBitmapSize ( maBitmap.GetSizePixel() )
{
- maMask = maBitmap.CreateMask( rTransparentColor );
+ maAlphaMask = maBitmap.CreateMask( rTransparentColor );
- SAL_WARN_IF(rBmp.GetSizePixel() != maMask.GetSizePixel(), "vcl",
+ SAL_WARN_IF(rBmp.GetSizePixel() != maAlphaMask.GetSizePixel(), "vcl",
"BitmapEx::BitmapEx(): size mismatch for bitmap and alpha mask.");
}
@@ -187,35 +165,24 @@ BitmapEx& BitmapEx::operator=( const BitmapEx& ) = default;
bool BitmapEx::operator==( const BitmapEx& rBitmapEx ) const
{
- if (meTransparent != rBitmapEx.meTransparent)
- return false;
-
if (GetSizePixel() != rBitmapEx.GetSizePixel())
return false;
- if (meTransparent != rBitmapEx.meTransparent)
- return false;
-
- if (mbAlpha != rBitmapEx.mbAlpha)
- return false;
-
if (maBitmap != rBitmapEx.maBitmap)
return false;
- return maMask == rBitmapEx.maMask;
+ return maAlphaMask == rBitmapEx.maAlphaMask;
}
bool BitmapEx::IsEmpty() const
{
- return( maBitmap.IsEmpty() && maMask.IsEmpty() );
+ return( maBitmap.IsEmpty() && maAlphaMask.IsEmpty() );
}
void BitmapEx::SetEmpty()
{
maBitmap.SetEmpty();
- maMask.SetEmpty();
- meTransparent = TransparentType::NONE;
- mbAlpha = false;
+ maAlphaMask.SetEmpty();
}
void BitmapEx::Clear()
@@ -223,14 +190,9 @@ void BitmapEx::Clear()
SetEmpty();
}
-bool BitmapEx::IsTransparent() const
-{
- return( meTransparent != TransparentType::NONE );
-}
-
bool BitmapEx::IsAlpha() const
{
- return( IsTransparent() && mbAlpha );
+ return !maAlphaMask.IsEmpty();
}
const Bitmap& BitmapEx::GetBitmap() const
@@ -242,49 +204,25 @@ Bitmap BitmapEx::GetBitmap( Color aTransparentReplaceColor ) const
{
Bitmap aRetBmp( maBitmap );
- if( meTransparent != TransparentType::NONE )
+ if( !maAlphaMask.IsEmpty() )
{
- Bitmap aTempMask = maMask;
-
- if( !IsAlpha() )
- aRetBmp.Replace( aTempMask, aTransparentReplaceColor );
- else
- aRetBmp.Replace( GetAlpha(), aTransparentReplaceColor );
+ aRetBmp.Replace( maAlphaMask, aTransparentReplaceColor );
}
return aRetBmp;
}
-Bitmap BitmapEx::GetMask() const
-{
- if (!IsAlpha())
- return maMask;
-
- BitmapEx aMaskEx(maMask);
- BitmapFilter::Filter(aMaskEx, BitmapMonochromeFilter(255));
- return aMaskEx.GetBitmap();
-}
-
AlphaMask BitmapEx::GetAlpha() const
{
- if( IsAlpha() )
- {
- AlphaMask aAlpha;
- aAlpha.ImplSetBitmap( maMask );
- return aAlpha;
- }
- else
- {
- return AlphaMask(maMask);
- }
+ return AlphaMask(maAlphaMask);
}
sal_uLong BitmapEx::GetSizeBytes() const
{
sal_uLong nSizeBytes = maBitmap.GetSizeBytes();
- if( meTransparent == TransparentType::Bitmap )
- nSizeBytes += maMask.GetSizeBytes();
+ if( !maAlphaMask.IsEmpty() )
+ nSizeBytes += maAlphaMask.GetSizeBytes();
return nSizeBytes;
}
@@ -292,18 +230,11 @@ sal_uLong BitmapEx::GetSizeBytes() const
BitmapChecksum BitmapEx::GetChecksum() const
{
BitmapChecksum nCrc = maBitmap.GetChecksum();
- SVBT32 aBT32;
-
- UInt32ToSVBT32( o3tl::underlyingEnumValue(meTransparent), aBT32 );
- nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
- UInt32ToSVBT32( sal_uInt32(mbAlpha), aBT32 );
- nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
-
- if( ( TransparentType::Bitmap == meTransparent ) && !maMask.IsEmpty() )
+ if( !maAlphaMask.IsEmpty() )
{
BitmapChecksumOctetArray aBCOA;
- BCToBCOA( maMask.GetChecksum(), aBCOA );
+ BCToBCOA( maAlphaMask.GetChecksum(), aBCOA );
nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
}
@@ -333,8 +264,8 @@ bool BitmapEx::Mirror( BmpMirrorFlags nMirrorFlags )
{
bRet = maBitmap.Mirror( nMirrorFlags );
- if( bRet && ( meTransparent == TransparentType::Bitmap ) && !maMask.IsEmpty() )
- maMask.Mirror( nMirrorFlags );
+ if( bRet && !maAlphaMask.IsEmpty() )
+ maAlphaMask.Mirror( nMirrorFlags );
}
return bRet;
@@ -348,14 +279,14 @@ bool BitmapEx::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag
{
bRet = maBitmap.Scale( rScaleX, rScaleY, nScaleFlag );
- if( bRet && ( meTransparent == TransparentType::Bitmap ) && !maMask.IsEmpty() )
+ if( bRet && !maAlphaMask.IsEmpty() )
{
- maMask.Scale( rScaleX, rScaleY, nScaleFlag );
+ maAlphaMask.Scale( rScaleX, rScaleY, nScaleFlag );
}
SetSizePixel(maBitmap.GetSizePixel());
- SAL_WARN_IF( !maMask.IsEmpty() && maBitmap.GetSizePixel() != maMask.GetSizePixel(), "vcl",
+ SAL_WARN_IF( !maAlphaMask.IsEmpty() && maBitmap.GetSizePixel() != maAlphaMask.GetSizePixel(), "vcl",
"BitmapEx::Scale(): size mismatch for bitmap and alpha mask." );
}
@@ -394,27 +325,26 @@ bool BitmapEx::Rotate( Degree10 nAngle10, const Color& rFillColor )
{
bRet = maBitmap.Rotate( nAngle10, COL_BLACK );
- if( meTransparent == TransparentType::NONE )
+ if( maAlphaMask.IsEmpty() )
{
- maMask = Bitmap(GetSizePixel(), vcl::PixelFormat::N1_BPP);
- maMask.Erase( COL_BLACK );
- meTransparent = TransparentType::Bitmap;
+ maAlphaMask = Bitmap(GetSizePixel(), vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256));
+ maAlphaMask.Erase( COL_BLACK );
}
- if( bRet && !maMask.IsEmpty() )
- maMask.Rotate( nAngle10, COL_WHITE );
+ if( bRet && !maAlphaMask.IsEmpty() )
+ maAlphaMask.Rotate( nAngle10, COL_WHITE );
}
else
{
bRet = maBitmap.Rotate( nAngle10, rFillColor );
- if( bRet && ( meTransparent == TransparentType::Bitmap ) && !maMask.IsEmpty() )
- maMask.Rotate( nAngle10, COL_WHITE );
+ if( bRet && !maAlphaMask.IsEmpty() )
+ maAlphaMask.Rotate( nAngle10, COL_WHITE );
}
SetSizePixel(maBitmap.GetSizePixel());
- SAL_WARN_IF(!maMask.IsEmpty() && maBitmap.GetSizePixel() != maMask.GetSizePixel(), "vcl",
+ SAL_WARN_IF(!maAlphaMask.IsEmpty() && maBitmap.GetSizePixel() != maAlphaMask.GetSizePixel(), "vcl",
"BitmapEx::Rotate(): size mismatch for bitmap and alpha mask.");
}
@@ -429,12 +359,12 @@ bool BitmapEx::Crop( const tools::Rectangle& rRectPixel )
{
bRet = maBitmap.Crop( rRectPixel );
- if( bRet && ( meTransparent == TransparentType::Bitmap ) && !maMask.IsEmpty() )
- maMask.Crop( rRectPixel );
+ if( bRet && !maAlphaMask.IsEmpty() )
+ maAlphaMask.Crop( rRectPixel );
SetSizePixel(maBitmap.GetSizePixel());
- SAL_WARN_IF(!maMask.IsEmpty() && maBitmap.GetSizePixel() != maMask.GetSizePixel(), "vcl",
+ SAL_WARN_IF(!maAlphaMask.IsEmpty() && maBitmap.GetSizePixel() != maAlphaMask.GetSizePixel(), "vcl",
"BitmapEx::Crop(): size mismatch for bitmap and alpha mask.");
}
@@ -455,15 +385,15 @@ void BitmapEx::Expand( sal_uLong nDX, sal_uLong nDY, bool bExpandTransparent )
bRet = maBitmap.Expand( nDX, nDY );
- if( bRet && ( meTransparent == TransparentType::Bitmap ) && !maMask.IsEmpty() )
+ if( bRet && !maAlphaMask.IsEmpty() )
{
Color aColor( bExpandTransparent ? COL_WHITE : COL_BLACK );
- maMask.Expand( nDX, nDY, &aColor );
+ maAlphaMask.Expand( nDX, nDY, &aColor );
}
SetSizePixel(maBitmap.GetSizePixel());
- SAL_WARN_IF(!maMask.IsEmpty() && maBitmap.GetSizePixel() != maMask.GetSizePixel(), "vcl",
+ SAL_WARN_IF(!maAlphaMask.IsEmpty() && maBitmap.GetSizePixel() != maAlphaMask.GetSizePixel(), "vcl",
"BitmapEx::Expand(): size mismatch for bitmap and alpha mask.");
}
@@ -478,8 +408,8 @@ bool BitmapEx::CopyPixel( const tools::Rectangle& rRectDst, const tools::Rectang
{
bRet = maBitmap.CopyPixel( rRectDst, rRectSrc );
- if( bRet && ( meTransparent == TransparentType::Bitmap ) && !maMask.IsEmpty() )
- maMask.CopyPixel( rRectDst, rRectSrc );
+ if( bRet && !maAlphaMask.IsEmpty() )
+ maAlphaMask.CopyPixel( rRectDst, rRectSrc );
}
}
else
@@ -494,45 +424,15 @@ bool BitmapEx::CopyPixel( const tools::Rectangle& rRectDst, const tools::Rectang
{
if( IsAlpha() )
// cast to use the optimized AlphaMask::CopyPixel
- maMask.CopyPixel_AlphaOptimized( rRectDst, rRectSrc, &pBmpExSrc->maMask );
- else if( IsTransparent() )
- {
- std::unique_ptr<AlphaMask> pAlpha(new AlphaMask( maMask ));
-
- maMask = pAlpha->ImplGetBitmap();
- pAlpha.reset();
- mbAlpha = true;
- maMask.CopyPixel( rRectDst, rRectSrc, &pBmpExSrc->maMask );
- }
+ maAlphaMask.CopyPixel_AlphaOptimized( rRectDst, rRectSrc, &pBmpExSrc->maAlphaMask );
else
{
sal_uInt8 cBlack = 0;
std::unique_ptr<AlphaMask> pAlpha(new AlphaMask(GetSizePixel(), &cBlack));
- maMask = pAlpha->ImplGetBitmap();
+ maAlphaMask = pAlpha->ImplGetBitmap();
pAlpha.reset();
- meTransparent = TransparentType::Bitmap;
- mbAlpha = true;
- maMask.CopyPixel( rRectDst, rRectSrc, &pBmpExSrc->maMask );
- }
- }
- else if( pBmpExSrc->IsTransparent() )
- {
- if (IsAlpha())
- {
- AlphaMask aAlpha( pBmpExSrc->maMask );
- maMask.CopyPixel( rRectDst, rRectSrc, &aAlpha.ImplGetBitmap() );
- }
- else if (IsTransparent())
- {
- maMask.CopyPixel( rRectDst, rRectSrc, &pBmpExSrc->maMask );
- }
- else
- {
- maMask = Bitmap(GetSizePixel(), vcl::PixelFormat::N1_BPP);
- maMask.Erase(COL_BLACK);
- meTransparent = TransparentType::Bitmap;
- maMask.CopyPixel( rRectDst, rRectSrc, &pBmpExSrc->maMask );
+ maAlphaMask.CopyPixel( rRectDst, rRectSrc, &pBmpExSrc->maAlphaMask );
}
}
else if (IsAlpha())
@@ -540,14 +440,7 @@ bool BitmapEx::CopyPixel( const tools::Rectangle& rRectDst, const tools::Rectang
sal_uInt8 cBlack = 0;
const AlphaMask aAlphaSrc(pBmpExSrc->GetSizePixel(), &cBlack);
- maMask.CopyPixel( rRectDst, rRectSrc, &aAlphaSrc.ImplGetBitmap() );
- }
- else if (IsTransparent())
- {
- Bitmap aMaskSrc(pBmpExSrc->GetSizePixel(), vcl::PixelFormat::N1_BPP);
-
- aMaskSrc.Erase( COL_BLACK );
- maMask.CopyPixel( rRectDst, rRectSrc, &aMaskSrc );
+ maAlphaMask.CopyPixel( rRectDst, rRectSrc, &aAlphaSrc.ImplGetBitmap() );
}
}
}
@@ -564,18 +457,18 @@ bool BitmapEx::Erase( const Color& rFillColor )
{
bRet = maBitmap.Erase( rFillColor );
- if( bRet && ( meTransparent == TransparentType::Bitmap ) && !maMask.IsEmpty() )
+ if( bRet && !maAlphaMask.IsEmpty() )
{
// Respect transparency on fill color
if( rFillColor.IsTransparent() )
{
const Color aFill( 255 - rFillColor.GetAlpha(), 255 - rFillColor.GetAlpha(), 255 - rFillColor.GetAlpha() );
- maMask.Erase( aFill );
+ maAlphaMask.Erase( aFill );
}
else
{
const Color aBlack( COL_BLACK );
- maMask.Erase( aBlack );
+ maAlphaMask.Erase( aBlack );
}
}
}
@@ -682,42 +575,22 @@ sal_uInt8 BitmapEx::GetAlpha(sal_Int32 nX, sal_Int32 nY) const
return GetPixelColor(nX, nY).GetAlpha();
sal_uInt8 nAlpha(0);
- switch(meTransparent)
+ if (maAlphaMask.IsEmpty())
{
- case TransparentType::NONE:
- {
- // Not transparent, ergo all covered
- nAlpha = 255;
- break;
- }
- case TransparentType::Bitmap:
- {
- if(!maMask.IsEmpty())
- {
- Bitmap aTestBitmap(maMask);
- Bitmap::ScopedReadAccess pRead(aTestBitmap);
-
- if(pRead)
- {
- const BitmapColor aBitmapColor(pRead->GetPixel(nY, nX));
+ // Not transparent, ergo all covered
+ nAlpha = 255;
+ }
+ else
+ {
+ Bitmap aTestBitmap(maAlphaMask);
+ Bitmap::ScopedReadAccess pRead(aTestBitmap);
- if(mbAlpha)
- {
- nAlpha = 255 - aBitmapColor.GetIndex();
- }
- else
- {
- if(0x00 == aBitmapColor.GetIndex())
- {
- nAlpha = 255;
- }
- }
- }
- }
- break;
+ if(pRead)
+ {
+ const BitmapColor aBitmapColor(pRead->GetPixel(nY, nX));
+ nAlpha = 255 - aBitmapColor.GetIndex();
}
}
-
return nAlpha;
}
@@ -891,18 +764,10 @@ BitmapEx BitmapEx::TransformBitmapEx(
const Bitmap aDestination(impTransformBitmap(GetBitmap(), aDestinationSize, rTransformation, bSmooth));
// create mask
- if(IsTransparent())
+ if(IsAlpha())
{
- if(IsAlpha())
- {
- const Bitmap aAlpha(impTransformBitmap(GetAlpha().GetBitmap(), aDestinationSize, rTransformation, bSmooth));
- return BitmapEx(aDestination, AlphaMask(aAlpha));
- }
- else
- {
- const Bitmap aLclMask(impTransformBitmap(GetMask(), aDestinationSize, rTransformation, false));
- return BitmapEx(aDestination, aLclMask);
- }
+ const Bitmap aAlpha(impTransformBitmap(GetAlpha().GetBitmap(), aDestinationSize, rTransformation, bSmooth));
+ return BitmapEx(aDestination, AlphaMask(aAlpha));
}
return BitmapEx(aDestination);
@@ -1002,7 +867,7 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod
if(pReplace)
{
// complete replace
- if(IsTransparent())
+ if(IsAlpha())
{
// clear bitmap with dest color
if (vcl::isPalettePixelFormat(aChangedBitmap.getPixelFormat()))
@@ -1122,16 +987,9 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod
}
else
{
- if(IsTransparent())
+ if(IsAlpha())
{
- if(IsAlpha())
- {
- return BitmapEx(aChangedBitmap, GetAlpha());
- }
- else
- {
- return BitmapEx(aChangedBitmap, GetMask());
- }
+ return BitmapEx(aChangedBitmap, GetAlpha());
}
else
{
@@ -1310,13 +1168,11 @@ void BitmapEx::Replace( const Color* pSearchColors,
void BitmapEx::ReplaceTransparency(const Color& rColor)
{
- if( IsTransparent() )
+ if( IsAlpha() )
{
- maBitmap.Replace( GetMask(), rColor );
- maMask = Bitmap();
+ maBitmap.Replace( GetAlpha(), rColor );
+ maAlphaMask = Bitmap();
maBitmapSize = maBitmap.GetSizePixel();
- meTransparent = TransparentType::NONE;
- mbAlpha = false;
}
}
@@ -1536,15 +1392,10 @@ void BitmapEx::AdjustTransparency(sal_uInt8 cTrans)
{
AlphaMask aAlpha;
- if (!IsTransparent())
+ if (!IsAlpha())
{
aAlpha = AlphaMask(GetSizePixel(), &cTrans);
}
- else if( !IsAlpha() )
- {
- aAlpha = GetMask();
- aAlpha.Replace( 0, cTrans );
- }
else
{
aAlpha = GetAlpha();
@@ -1592,10 +1443,9 @@ void BitmapEx::AdjustTransparency(sal_uInt8 cTrans)
void BitmapEx::CombineMaskOr(Color maskColor, sal_uInt8 nTol)
{
Bitmap aNewMask = maBitmap.CreateMask( maskColor, nTol );
- if ( IsTransparent() )
- aNewMask.CombineSimple( maMask, BmpCombine::Or );
- maMask = aNewMask;
- meTransparent = TransparentType::Bitmap;
+ if ( IsAlpha() )
+ aNewMask.CombineSimple( maAlphaMask, BmpCombine::Or );
+ maAlphaMask = aNewMask;
}
/**
@@ -1628,7 +1478,7 @@ void BitmapEx::GetColorModel(css::uno::Sequence< sal_Int32 >& rRGBPalette,
*pTmp |= sal_Int32(0x000000ffL);
}
- if( IsTransparent() )
+ if( IsAlpha() )
{
// append transparent entry
*pTmp = sal_Int32(0xffffff00L);
diff --git a/vcl/source/bitmap/BitmapFastScaleFilter.cxx b/vcl/source/bitmap/BitmapFastScaleFilter.cxx
index feeee6c79931..0a1143d28e04 100644
--- a/vcl/source/bitmap/BitmapFastScaleFilter.cxx
+++ b/vcl/source/bitmap/BitmapFastScaleFilter.cxx
@@ -112,9 +112,9 @@ BitmapEx BitmapFastScaleFilter::execute(BitmapEx const& rBitmapEx) const
}
}
- Bitmap aMask(rBitmapEx.GetMask());
+ AlphaMask aMask(rBitmapEx.GetAlpha());
- if (bRet && (rBitmapEx.GetTransparentType() == TransparentType::Bitmap) && !aMask.IsEmpty())
+ if (bRet && !aMask.IsEmpty())
bRet = aMask.Scale(maSize, BmpScaleFlag::Fast);
SAL_WARN_IF(!aMask.IsEmpty() && aBitmap.GetSizePixel() != aMask.GetSizePixel(), "vcl",
diff --git a/vcl/source/bitmap/BitmapFilterStackBlur.cxx b/vcl/source/bitmap/BitmapFilterStackBlur.cxx
index 027b84c5958d..c23adad0176f 100644
--- a/vcl/source/bitmap/BitmapFilterStackBlur.cxx
+++ b/vcl/source/bitmap/BitmapFilterStackBlur.cxx
@@ -624,7 +624,7 @@ BitmapEx BitmapFilterStackBlur::execute(BitmapEx const& rBitmapEx) const
{
Bitmap aBitmap = rBitmapEx.GetBitmap();
Bitmap result = filter(aBitmap);
- return BitmapEx(result, rBitmapEx.GetMask());
+ return BitmapEx(result, rBitmapEx.GetAlpha());
}
Bitmap BitmapFilterStackBlur::filter(Bitmap const& rBitmap) const
diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index 168cf95fb9e0..32204a4a2bb1 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -341,22 +341,19 @@ BitmapEx CanvasTransformBitmap( const BitmapEx& rBitmap,
// differentiate mask and alpha channel (on-off
// vs. multi-level transparency)
- if( rBitmap.IsTransparent() )
+ if( rBitmap.IsAlpha() )
{
- if( rBitmap.IsAlpha() )
- aSrcAlpha = rBitmap.GetAlpha().GetBitmap();
- else
- aSrcAlpha = rBitmap.GetMask();
+ aSrcAlpha = rBitmap.GetAlpha().GetBitmap();
}
Bitmap::ScopedReadAccess pReadAccess( aSrcBitmap );
- Bitmap::ScopedReadAccess pAlphaReadAccess( rBitmap.IsTransparent() ?
+ Bitmap::ScopedReadAccess pAlphaReadAccess( rBitmap.IsAlpha() ?
aSrcAlpha.AcquireReadAccess() :
nullptr,
aSrcAlpha );
if( pReadAccess.get() == nullptr ||
- (pAlphaReadAccess.get() == nullptr && rBitmap.IsTransparent()) )
+ (pAlphaReadAccess.get() == nullptr && rBitmap.IsAlpha()) )
{
// TODO(E2): Error handling!
ENSURE_OR_THROW( false,
@@ -368,29 +365,15 @@ BitmapEx CanvasTransformBitmap( const BitmapEx& rBitmap,
// paletted 1-bit masks).
sal_uInt8 aAlphaMap[256];
- if( rBitmap.IsTransparent() )
+ if( rBitmap.IsAlpha() )
{
- if( rBitmap.IsAlpha() )
- {
- // source already has alpha channel - 1:1 mapping,
- // i.e. aAlphaMap[0]=0,...,aAlphaMap[255]=255.
- sal_uInt8 val=0;
- sal_uInt8* pCur=aAlphaMap;
- sal_uInt8* const pEnd=&aAlphaMap[256];
- while(pCur != pEnd)
- *pCur++ = val++;
- }
- else
- {
- // mask transparency - determine used palette colors
- const BitmapColor& rCol0( pAlphaReadAccess->GetPaletteColor( 0 ) );
- const BitmapColor& rCol1( pAlphaReadAccess->GetPaletteColor( 1 ) );
-
- // shortcut for true luminance calculation
- // (assumes that palette is grey-level)
- aAlphaMap[0] = rCol0.GetRed();
- aAlphaMap[1] = rCol1.GetRed();
- }
+ // source already has alpha channel - 1:1 mapping,
+ // i.e. aAlphaMap[0]=0,...,aAlphaMap[255]=255.
+ sal_uInt8 val=0;
+ sal_uInt8* pCur=aAlphaMap;
+ sal_uInt8* const pEnd=&aAlphaMap[256];
+ while(pCur != pEnd)
+ *pCur++ = val++;
}
// else: mapping table is not used
@@ -428,7 +411,7 @@ BitmapEx CanvasTransformBitmap( const BitmapEx& rBitmap,
{
// differentiate mask and alpha channel (on-off
// vs. multi-level transparency)
- if( rBitmap.IsTransparent() )
+ if( rBitmap.IsAlpha() )
{
Scanline pScan = pWriteAccess->GetScanline( y );
Scanline pScanAlpha = pAlphaWriteAccess->GetScanline( y );
@@ -500,10 +483,6 @@ void DrawAlphaBitmapAndAlphaGradient(BitmapEx & rBitmapEx, bool bFixedTransparen
{
aOldMask = rBitmapEx.GetAlpha();
}
- else if(TransparentType::Bitmap == rBitmapEx.GetTransparentType())
- {
- aOldMask = rBitmapEx.GetMask();
- }
{
AlphaScopedWriteAccess pOld(aOldMask);
@@ -580,55 +559,43 @@ void DrawAndClipBitmap(const Point& rPos, const Size& rSize, const BitmapEx& rBi
pVDev->EnableMapMode( false );
const Bitmap aVDevMask(pVDev->GetBitmap(Point(), aSizePixel));
- if(aBmpEx.IsTransparent())
+ if(aBmpEx.IsAlpha())
{
// bitmap already uses a Mask or Alpha, we need to blend that with
- // the new masking in pVDev
- if(aBmpEx.IsAlpha())
+ // the new masking in pVDev.
+ // need to blend in AlphaMask quality (8Bit)
+ AlphaMask fromVDev(aVDevMask);
+ AlphaMask fromBmpEx(aBmpEx.GetAlpha());
+ AlphaMask::ScopedReadAccess pR(fromVDev);
+ AlphaScopedWriteAccess pW(fromBmpEx);
+
+ if(pR && pW)
{
- // need to blend in AlphaMask quality (8Bit)
- AlphaMask fromVDev(aVDevMask);
- AlphaMask fromBmpEx(aBmpEx.GetAlpha());
- AlphaMask::ScopedReadAccess pR(fromVDev);
- AlphaScopedWriteAccess pW(fromBmpEx);
+ const tools::Long nWidth(std::min(pR->Width(), pW->Width()));
+ const tools::Long nHeight(std::min(pR->Height(), pW->Height()));
- if(pR && pW)
+ for(tools::Long nY(0); nY < nHeight; nY++)
{
- const tools::Long nWidth(std::min(pR->Width(), pW->Width()));
- const tools::Long nHeight(std::min(pR->Height(), pW->Height()));
-
- for(tools::Long nY(0); nY < nHeight; nY++)
+ Scanline pScanlineR = pR->GetScanline( nY );
+ Scanline pScanlineW = pW->GetScanline( nY );
+ for(tools::Long nX(0); nX < nWidth; nX++)
{
- Scanline pScanlineR = pR->GetScanline( nY );
- Scanline pScanlineW = pW->GetScanline( nY );
- for(tools::Long nX(0); nX < nWidth; nX++)
- {
- const sal_uInt8 nIndR(pR->GetIndexFromData(pScanlineR, nX));
- const sal_uInt8 nIndW(pW->GetIndexFromData(pScanlineW, nX));
+ const sal_uInt8 nIndR(pR->GetIndexFromData(pScanlineR, nX));
+ const sal_uInt8 nIndW(pW->GetIndexFromData(pScanlineW, nX));
- // these values represent transparency (0 == no, 255 == fully transparent),
- // so to blend these we have to multiply the inverse (opacity)
- // and re-invert the result to transparence
- const sal_uInt8 nCombined(0x00ff - (((0x00ff - nIndR) * (0x00ff - nIndW)) >> 8));
+ // these values represent transparency (0 == no, 255 == fully transparent),
+ // so to blend these we have to multiply the inverse (opacity)
+ // and re-invert the result to transparence
+ const sal_uInt8 nCombined(0x00ff - (((0x00ff - nIndR) * (0x00ff - nIndW)) >> 8));
- pW->SetPixelOnData(pScanlineW, nX, BitmapColor(nCombined));
- }
+ pW->SetPixelOnData(pScanlineW, nX, BitmapColor(nCombined));
}
}
-
- pR.reset();
- pW.reset();
- aBmpEx = BitmapEx(aBmpEx.GetBitmap(), fromBmpEx);
}
- else
- {
- // need to blend in Mask quality (1Bit)
- Bitmap aMask(aVDevMask.CreateMask(COL_WHITE));
-
- aMask.CombineSimple( rBitmap.GetMask(), BmpCombine::And );
- aBmpEx = BitmapEx( rBitmap.GetBitmap(), aMask );
- }
+ pR.reset();
+ pW.reset();
+ aBmpEx = BitmapEx(aBmpEx.GetBitmap(), fromBmpEx);
}
else
{
@@ -647,12 +614,6 @@ css::uno::Sequence< sal_Int8 > GetMaskDIB(BitmapEx const & aBmpEx)
WriteDIB(aBmpEx.GetAlpha().GetBitmap(), aMem, false, true);
return css::uno::Sequence< sal_Int8 >( static_cast<sal_Int8 const *>(aMem.GetData()), aMem.Tell() );
}
- else if ( aBmpEx.IsTransparent() )
- {
- SvMemoryStream aMem;
- WriteDIB(aBmpEx.GetMask(), aMem, false, true);
- return css::uno::Sequence< sal_Int8 >( static_cast<sal_Int8 const *>(aMem.GetData()), aMem.Tell() );
- }
return css::uno::Sequence< sal_Int8 >();
}
@@ -712,7 +673,7 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un
tools::Long nX, nY;
bool bIsAlpha = false;
- if( aBmpEx.IsTransparent() || aBmpEx.IsAlpha() )
+ if( aBmpEx.IsAlpha() )
pAlphaReadAcc = aAlpha.AcquireReadAccess();
data = static_cast<unsigned char*>(malloc( nWidth*nHeight*4 ));
@@ -1007,7 +968,7 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un
{
bool bRet(false);
- if(!rBitmapEx.IsTransparent())
+ if(!rBitmapEx.IsAlpha())
{
Bitmap aBitmap(rBitmapEx.GetBitmap());
@@ -1162,7 +1123,7 @@ bool convertBitmap32To24Plus8(BitmapEx const & rInput, BitmapEx & rResult)
}
}
}
- if (rInput.IsTransparent())
+ if (rInput.IsAlpha())
rResult = BitmapEx(aResultBitmap, rInput.GetAlpha());
else
rResult = BitmapEx(aResultBitmap, aResultAlpha);
diff --git a/vcl/source/bitmap/bitmapfilter.cxx b/vcl/source/bitmap/bitmapfilter.cxx
index 70d9cdd62dc1..f2020539e04d 100644
--- a/vcl/source/bitmap/bitmapfilter.cxx
+++ b/vcl/source/bitmap/bitmapfilter.cxx
@@ -23,7 +23,7 @@ bool BitmapFilter::Filter(BitmapEx& rBmpEx, BitmapFilter const& rFilter)
if (aTmpBmpEx.IsEmpty())
{
- SAL_WARN("vcl.gdi", "Bitmap filter failed");
+ SAL_WARN("vcl.gdi", "Bitmap filter failed " << typeid(rFilter).name());
return false;
}
diff --git a/vcl/source/bitmap/dibtools.cxx b/vcl/source/bitmap/dibtools.cxx
index f583ca0b332e..407deaeb4f9f 100644
--- a/vcl/source/bitmap/dibtools.cxx
+++ b/vcl/source/bitmap/dibtools.cxx
@@ -1737,7 +1737,7 @@ bool ReadDIBBitmapEx(
{
switch (tmp)
{
- case static_cast<int>(TransparentType::Bitmap):
+ case 2: // TransparentType::Bitmap
{
Bitmap aMask;
@@ -1845,11 +1845,11 @@ bool WriteDIBBitmapEx(
{
rOStm.WriteUInt32( 0x25091962 );
rOStm.WriteUInt32( 0xACB20201 );
- rOStm.WriteUChar( static_cast<unsigned char>(rSource.meTransparent) );
+ rOStm.WriteUChar( rSource.IsAlpha() ? 2 : 0 ); // Used to be TransparentType enum
- if(TransparentType::Bitmap == rSource.meTransparent)
+ if(rSource.IsAlpha())
{
- return ImplWriteDIB(rSource.maMask, rOStm, true, true);
+ return ImplWriteDIB(rSource.maAlphaMask, rOStm, true, true);
}
}
diff --git a/vcl/source/control/ivctrl.cxx b/vcl/source/control/ivctrl.cxx
index 998a44888aee..c96e133a506f 100644
--- a/vcl/source/control/ivctrl.cxx
+++ b/vcl/source/control/ivctrl.cxx
@@ -343,7 +343,7 @@ void SvtIconChoiceCtrl::SetBackground( const Wallpaper& rPaper )
Color aBack( aBackground.GetColor());
if( aBack == COL_TRANSPARENT &&
(!aBackground.IsBitmap() ||
- aBackground.GetBitmap().IsTransparent() ||
+ aBackground.GetBitmap().IsAlpha() ||
(eStyle != WallpaperStyle::Tile && eStyle != WallpaperStyle::Scale)) )
{
aBackground.SetColor( rStyleSettings.GetFieldColor() );
diff --git a/vcl/source/filter/egif/egif.cxx b/vcl/source/filter/egif/egif.cxx
index 79caa7db584b..660ebf95333c 100644
--- a/vcl/source/filter/egif/egif.cxx
+++ b/vcl/source/filter/egif/egif.cxx
@@ -242,7 +242,7 @@ bool GIFWriter::CreateAccess( const BitmapEx& rBmpEx )
{
if( bStatus )
{
- Bitmap aMask( rBmpEx.GetMask() );
+ Bitmap aMask( rBmpEx.GetAlpha() );
aAccBmp = rBmpEx.GetBitmap();
bTransparent = false;
diff --git a/vcl/source/filter/eps/eps.cxx b/vcl/source/filter/eps/eps.cxx
index 567512554c90..fbea39008af9 100644
--- a/vcl/source/filter/eps/eps.cxx
+++ b/vcl/source/filter/eps/eps.cxx
@@ -824,7 +824,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev )
Bitmap aBitmap( aBitmapEx.GetBitmap() );
if ( mbGrayScale )
aBitmap.Convert( BmpConversion::N8BitGreys );
- Bitmap aMask( aBitmapEx.GetMask() );
+ Bitmap aMask( aBitmapEx.GetAlpha() );
Point aPoint( static_cast<const MetaBmpExAction*>(pMA)->GetPoint() );
Size aSize( rVDev.PixelToLogic( aBitmap.GetSizePixel() ) );
ImplBmp( &aBitmap, &aMask, aPoint, aSize.Width(), aSize.Height() );
@@ -837,7 +837,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev )
Bitmap aBitmap( aBitmapEx.GetBitmap() );
if ( mbGrayScale )
aBitmap.Convert( BmpConversion::N8BitGreys );
- Bitmap aMask( aBitmapEx.GetMask() );
+ Bitmap aMask( aBitmapEx.GetAlpha() );
Point aPoint = static_cast<const MetaBmpExScaleAction*>(pMA)->GetPoint();
Size aSize( static_cast<const MetaBmpExScaleAction*>(pMA)->GetSize() );
ImplBmp( &aBitmap, &aMask, aPoint, aSize.Width(), aSize.Height() );
@@ -852,7 +852,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev )
Bitmap aBitmap( aBitmapEx.GetBitmap() );
if ( mbGrayScale )
aBitmap.Convert( BmpConversion::N8BitGreys );
- Bitmap aMask( aBitmapEx.GetMask() );
+ Bitmap aMask( aBitmapEx.GetAlpha() );
Point aPoint = static_cast<const MetaBmpExScalePartAction*>(pMA)->GetDestPoint();
Size aSize = static_cast<const MetaBmpExScalePartAction*>(pMA)->GetDestSize();
ImplBmp( &aBitmap, &aMask, aPoint, aSize.Width(), aSize.Height() );
@@ -904,7 +904,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev )
{
BitmapEx aBitmapEx = aWallpaper.GetBitmap();
Bitmap aBitmap( aBitmapEx.GetBitmap() );
- if ( aBitmapEx.IsTransparent() )
+ if ( aBitmapEx.IsAlpha() )
{
if ( aWallpaper.IsGradient() )
{
@@ -912,7 +912,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev )
// gradient action
}
- Bitmap aMask( aBitmapEx.GetMask() );
+ Bitmap aMask( aBitmapEx.GetAlpha() );
ImplBmp( &aBitmap, &aMask, Point( aRect.Left(), aRect.Top() ), aRect.GetWidth(), aRect.GetHeight() );
}
else
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 9de2f801c790..b6ebf1d4aace 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -659,8 +659,6 @@ void GraphicFilter::ImportGraphics(std::vector< std::shared_ptr<Graphic> >& rGra
const BitmapEx& rBitmapEx = rContext.m_pGraphic->GetBitmapExRef();
Bitmap& rBitmap = const_cast<Bitmap&>(rBitmapEx.GetBitmap());
rContext.m_pAccess = std::make_unique<BitmapScopedWriteAccess>(rBitmap);
- // The png reader either uses only Bitmap or Bitmap+AlphaMask.
- assert(rBitmapEx.IsAlpha() || !rBitmapEx.IsTransparent());
if(rBitmapEx.IsAlpha())
{
// The separate alpha bitmap causes a number of complications. Not only
diff --git a/vcl/source/filter/png/pngwrite.cxx b/vcl/source/filter/png/pngwrite.cxx
index 379c805f313b..0554a314e83c 100644
--- a/vcl/source/filter/png/pngwrite.cxx
+++ b/vcl/source/filter/png/pngwrite.cxx
@@ -40,7 +40,6 @@
#define PNGCHUNK_IDAT 0x49444154
#define PNGCHUNK_IEND 0x49454e44
#define PNGCHUNK_pHYs 0x70485973
-#define PNGCHUNK_tRNS 0x74524e53
namespace vcl
{
@@ -83,7 +82,6 @@ private:
void ImplWriteIDAT();
sal_uLong ImplGetFilter(sal_uLong nY, sal_uLong nXStart = 0, sal_uLong nXAdd = 1);
void ImplClearFirstScanline();
- void ImplWriteTransparent();
bool ImplWriteHeader();
void ImplWritePalette();
void ImplOpenChunk(sal_uLong nChunkType);
@@ -144,86 +142,39 @@ PNGWriterImpl::PNGWriterImpl(const BitmapEx& rBitmapEx,
}
mnBitsPerPixel = sal_uInt8(vcl::pixelFormatBitCount(aBmp.getPixelFormat()));
- if (aBitmapEx.IsTransparent())
+ if (aBitmapEx.IsAlpha())
{
- if (mnBitsPerPixel <= 8 && aBitmapEx.IsAlpha())
+ if (mnBitsPerPixel <= 8)
{
aBmp.Convert(BmpConversion::N24Bit);
mnBitsPerPixel = 24;
}
- if (mnBitsPerPixel <= 8) // transparent palette
+ mpAccess = Bitmap::ScopedReadAccess(aBmp); // true RGB with alphachannel
+ if (mpAccess)
{
- aBmp.Convert(BmpConversion::N8BitTrans);
- aBmp.Replace(aBitmapEx.GetMask(), BMP_COL_TRANS);
- mnBitsPerPixel = 8;
- mpAccess = Bitmap::ScopedReadAccess(aBmp);
- if (mpAccess)
+ mbTrueAlpha = true;
+ AlphaMask aMask(aBitmapEx.GetAlpha());
+ mpMaskAccess = aMask.AcquireReadAccess();
+ if (mpMaskAccess)
{
if (ImplWriteHeader())
{
ImplWritepHYs(aBitmapEx);
- ImplWritePalette();
- ImplWriteTransparent();
ImplWriteIDAT();
}
- mpAccess.reset();
+ aMask.ReleaseAccess(mpMaskAccess);
+ mpMaskAccess = nullptr;
}
else
{
mbStatus = false;
}
+ mpAccess.reset();
}
else
{
- mpAccess = Bitmap::ScopedReadAccess(aBmp); // true RGB with alphachannel
- if (mpAccess)
- {
- mbTrueAlpha = aBitmapEx.IsAlpha();
- if (mbTrueAlpha)
- {
- AlphaMask aMask(aBitmapEx.GetAlpha());
- mpMaskAccess = aMask.AcquireReadAccess();
- if (mpMaskAccess)
- {
- if (ImplWriteHeader())
- {
- ImplWritepHYs(aBitmapEx);
- ImplWriteIDAT();
- }
- aMask.ReleaseAccess(mpMaskAccess);
- mpMaskAccess = nullptr;
- }
- else
- {
- mbStatus = false;
- }
- }
- else
- {
- Bitmap aMask(aBitmapEx.GetMask());
- mpMaskAccess = aMask.AcquireReadAccess();
- if (mpMaskAccess)
- {
- if (ImplWriteHeader())
- {
- ImplWritepHYs(aBitmapEx);
- ImplWriteIDAT();
- }
- Bitmap::ReleaseAccess(mpMaskAccess);
- mpMaskAccess = nullptr;
- }
- else
- {
- mbStatus = false;
- }
- }
- mpAccess.reset();
- }
- else
- {
- mbStatus = false;
- }
+ mbStatus = false;
}
}
else
@@ -339,19 +290,6 @@ void PNGWriterImpl::ImplWritePalette()
ImplWriteChunk(pTempBuf.get(), nCount * 3);
}
-void PNGWriterImpl::ImplWriteTransparent()
-{
- const sal_uLong nTransIndex = mpAccess->GetBestPaletteIndex(BMP_COL_TRANS);
-
- ImplOpenChunk(PNGCHUNK_tRNS);
-
- for (sal_uLong n = 0; n <= nTransIndex; n++)
- {
- ImplWriteChunk((nTransIndex == n) ? static_cast<sal_uInt8>(0x0)
- : static_cast<sal_uInt8>(0xff));
- }
-}
-
void PNGWriterImpl::ImplWritepHYs(const BitmapEx& rBmpEx)
{
if (rBmpEx.GetPrefMapMode().GetMapUnit() != MapUnit::Map100thMM)
diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx
index 432af89ee774..9776de87e182 100644
--- a/vcl/source/filter/wmf/emfwr.cxx
+++ b/vcl/source/filter/wmf/emfwr.cxx
@@ -1289,7 +1289,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
{
const MetaBmpExAction* pA = static_cast<const MetaBmpExAction *>(pAction);
Bitmap aBmp( pA->GetBitmapEx().GetBitmap() );
- Bitmap aMsk( pA->GetBitmapEx().GetMask() );
+ Bitmap aMsk( pA->GetBitmapEx().GetAlpha() );
if( !aMsk.IsEmpty() )
{
@@ -1307,7 +1307,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
{
const MetaBmpExScaleAction* pA = static_cast<const MetaBmpExScaleAction*>(pAction);
Bitmap aBmp( pA->GetBitmapEx().GetBitmap() );
- Bitmap aMsk( pA->GetBitmapEx().GetMask() );
+ Bitmap aMsk( pA->GetBitmapEx().GetAlpha() );
if( !aMsk.IsEmpty() )
{
@@ -1327,7 +1327,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
BitmapEx aBmpEx( pA->GetBitmapEx() );
aBmpEx.Crop( tools::Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) );
Bitmap aBmp( aBmpEx.GetBitmap() );
- Bitmap aMsk( aBmpEx.GetMask() );
+ Bitmap aMsk( aBmpEx.GetAlpha() );
if( !aMsk.IsEmpty() )
{
diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx
index efb1c56403ac..2fa1a0839d38 100644
--- a/vcl/source/filter/wmf/wmfwr.cxx
+++ b/vcl/source/filter/wmf/wmfwr.cxx
@@ -1245,7 +1245,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF )
{
const MetaBmpExAction* pA = static_cast<const MetaBmpExAction *>(pMA);
Bitmap aBmp( pA->GetBitmapEx().GetBitmap() );
- Bitmap aMsk( pA->GetBitmapEx().GetMask() );
+ Bitmap aMsk( pA->GetBitmapEx().GetAlpha() );
if( !aMsk.IsEmpty() )
{
@@ -1263,7 +1263,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF )
{
const MetaBmpExScaleAction* pA = static_cast<const MetaBmpExScaleAction*>(pMA);
Bitmap aBmp( pA->GetBitmapEx().GetBitmap() );
- Bitmap aMsk( pA->GetBitmapEx().GetMask() );
+ Bitmap aMsk( pA->GetBitmapEx().GetAlpha() );
if( !aMsk.IsEmpty() )
{
@@ -1283,7 +1283,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF )
BitmapEx aBmpEx( pA->GetBitmapEx() );
aBmpEx.Crop( tools::Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) );
Bitmap aBmp( aBmpEx.GetBitmap() );
- Bitmap aMsk( aBmpEx.GetMask() );
+ Bitmap aMsk( aBmpEx.GetAlpha() );
if( !aMsk.IsEmpty() )
{
diff --git a/vcl/source/gdi/gdimetafiletools.cxx b/vcl/source/gdi/gdimetafiletools.cxx
index e0b96a6ba5ce..9b3e26afb331 100644
--- a/vcl/source/gdi/gdimetafiletools.cxx
+++ b/vcl/source/gdi/gdimetafiletools.cxx
@@ -171,7 +171,7 @@ namespace
aVDev->SetFillColor( COL_WHITE);
aVDev->SetLineColor();
- if(rBitmapEx.IsTransparent())
+ if(rBitmapEx.IsAlpha())
{
// use given alpha channel
aVDev->DrawBitmap(Point(0, 0), rBitmapEx.GetAlpha().GetBitmap());
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 2856ecaed18e..a31f8e768ece 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -1780,8 +1780,6 @@ BitmapEx GDIMetaFile::ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpPa
if( rBmpEx.IsAlpha() )
return BitmapEx( aBmp, rBmpEx.GetAlpha() );
- else if( rBmpEx.IsTransparent() )
- return BitmapEx( aBmp, rBmpEx.GetMask() );
else
return BitmapEx( aBmp );
}
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index b06423adbe3e..91f2bca31189 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -466,7 +466,7 @@ bool ImpGraphic::isTransparent() const
}
else if (meType == GraphicType::Bitmap && !maVectorGraphicData)
{
- bRet = mpAnimation ? mpAnimation->IsTransparent() : maBitmapEx.IsTransparent();
+ bRet = mpAnimation ? mpAnimation->IsTransparent() : maBitmapEx.IsAlpha();
}
return bRet;
@@ -741,7 +741,7 @@ const GDIMetaFile& ImpGraphic::getGDIMetaFile() const
// #123983# directly create a metafile with the same PrefSize and PrefMapMode
// the bitmap has, this will be an always correct metafile
- if(maBitmapEx.IsTransparent())
+ if(maBitmapEx.IsAlpha())
{
pThat->maMetaFile.AddAction(new MetaBmpExScaleAction(Point(), maBitmapEx.GetPrefSize(), maBitmapEx));
}
diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index 373eb2b20a69..d612898e6c8c 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -331,14 +331,12 @@ OString convertLineStyleToString(const MetaActionType nActionType)
return "";
}
-OUString convertBitmapExTransparentType(TransparentType eType)
+OUString convertBitmapExTransparentType(BitmapEx const & rBitmapEx)
{
- switch (eType)
- {
- default:
- case TransparentType::NONE: return "none";
- case TransparentType::Bitmap: return "bitmap";
- }
+ if (rBitmapEx.IsAlpha())
+ return "bitmap";
+ else
+ return "none";
}
OUString convertMapUnitToString(MapUnit eUnit)
@@ -856,7 +854,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
rWriter.startElement(sCurrentElementTag);
writePoint(rWriter, pMeta->GetPoint());
rWriter.attribute("crc", hex32(pMeta->GetBitmapEx().GetBitmap().GetChecksum()));
- rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx().GetTransparentType()));
+ rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx()));
rWriter.endElement();
}
break;
@@ -868,7 +866,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
writePoint(rWriter, pMeta->GetPoint());
writeSize(rWriter, pMeta->GetSize());
rWriter.attribute("crc", hex32(pMeta->GetBitmapEx().GetBitmap().GetChecksum()));
- rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx().GetTransparentType()));
+ rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx()));
rWriter.endElement();
}
break;
@@ -886,7 +884,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
rWriter.attribute("srcwidth", pMeta->GetSrcSize().Width());
rWriter.attribute("srcheight", pMeta->GetSrcSize().Height());
rWriter.attribute("crc", hex32(pMeta->GetBitmapEx().GetBitmap().GetChecksum()));
- rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx().GetTransparentType()));
+ rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx()));
rWriter.endElement();
}
break;
@@ -1002,7 +1000,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
rWriter.startElement("bitmap");
BitmapEx const & rBitmapEx = rWallpaper.GetBitmap();
rWriter.attribute("crc", hex32(rBitmapEx.GetChecksum()));
- rWriter.attribute("transparenttype", convertBitmapExTransparentType(rBitmapEx.GetTransparentType()));
+ rWriter.attribute("transparenttype", convertBitmapExTransparentType(rBitmapEx));
rWriter.attribute("pixelformat", convertPixelFormatToString(rBitmapEx.GetBitmap().getPixelFormat()));
rWriter.attribute("width", hex32(rBitmapEx.GetSizePixel().Width()));
rWriter.attribute("height", hex32(rBitmapEx.GetSizePixel().Height()));
diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx
index fc431c7e65a2..96a77a15d94d 100644
--- a/vcl/source/gdi/pdfextoutdevdata.cxx
+++ b/vcl/source/gdi/pdfextoutdevdata.cxx
@@ -451,12 +451,11 @@ bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAc
rWriter.SetClipRegion( aRect);
}
- Bitmap aMask;
+ AlphaMask aAlphaMask;
if (nTransparency)
{
- AlphaMask aAlphaMask(aGraphic.GetSizePixel());
+ aAlphaMask = AlphaMask(aGraphic.GetSizePixel());
aAlphaMask.Erase(nTransparency);
- aMask = aAlphaMask.GetBitmap();
}
SvMemoryStream aTmp;
@@ -483,7 +482,7 @@ bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAc
}
}
auto ePixelFormat = aGraphic.GetBitmapEx().getPixelFormat();
- rWriter.DrawJPGBitmap(aTmp, ePixelFormat > vcl::PixelFormat::N8_BPP, aGraphic.GetSizePixel(), aOutputRect, aMask, aGraphic);
+ rWriter.DrawJPGBitmap(aTmp, ePixelFormat > vcl::PixelFormat::N8_BPP, aGraphic.GetSizePixel(), aOutputRect, aAlphaMask, aGraphic);
}
if ( bClippingNeeded )
diff --git a/vcl/source/gdi/pdfwriter.cxx b/vcl/source/gdi/pdfwriter.cxx
index ab7a03cb205c..53609379bca8 100644
--- a/vcl/source/gdi/pdfwriter.cxx
+++ b/vcl/source/gdi/pdfwriter.cxx
@@ -323,9 +323,9 @@ void PDFWriter::SetTextAlign( ::TextAlign eAlign )
xImplementation->setTextAlign( eAlign );
}
-void PDFWriter::DrawJPGBitmap( SvStream& rStreamData, bool bIsTrueColor, const Size& rSrcSizePixel, const tools::Rectangle& rTargetArea, const Bitmap& rMask, const Graphic& rGraphic )
+void PDFWriter::DrawJPGBitmap( SvStream& rStreamData, bool bIsTrueColor, const Size& rSrcSizePixel, const tools::Rectangle& rTargetArea, const AlphaMask& rAlphaMask, const Graphic& rGraphic )
{
- xImplementation->drawJPGBitmap( rStreamData, bIsTrueColor, rSrcSizePixel, rTargetArea, rMask, rGraphic );
+ xImplementation->drawJPGBitmap( rStreamData, bIsTrueColor, rSrcSizePixel, rTargetArea, rAlphaMask, rGraphic );
}
sal_Int32 PDFWriter::CreateLink( const tools::Rectangle& rRect, sal_Int32 nPageNr )
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index ad9c1e0935e4..99918b8df1b1 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -1735,7 +1735,7 @@ void PDFWriterImpl::endPage()
{
writeJPG( jpeg );
jpeg.m_pStream.reset();
- jpeg.m_aMask = Bitmap();
+ jpeg.m_aAlphaMask = AlphaMask();
}
}
for (auto & item : m_aTransparentObjects)
@@ -8368,12 +8368,10 @@ void PDFWriterImpl::writeJPG( JPGEmit& rObject )
rObject.m_pStream->Seek( STREAM_SEEK_TO_BEGIN );
sal_Int32 nMaskObject = 0;
- if( !rObject.m_aMask.IsEmpty() )
+ if( !rObject.m_aAlphaMask.IsEmpty() )
{
- if (rObject.m_aMask.getPixelFormat() == vcl::PixelFormat::N1_BPP
- || (rObject.m_aMask.getPixelFormat() == vcl::PixelFormat::N8_BPP
- && m_aContext.Version >= PDFWriter::PDFVersion::PDF_1_4
- && !m_bIsPDF_A1))
+ if (m_aContext.Version >= PDFWriter::PDFVersion::PDF_1_4
+ && !m_bIsPDF_A1)
{
nMaskObject = createObject();
}
@@ -8404,7 +8402,7 @@ void PDFWriterImpl::writeJPG( JPGEmit& rObject )
aLine.append( nLength );
if( nMaskObject )
{
- aLine.append(rObject.m_aMask.getPixelFormat() == vcl::PixelFormat::N1_BPP ? " /Mask " : " /SMask ");
+ aLine.append(" /SMask ");
aLine.append( nMaskObject );
aLine.append( " 0 R " );
}
@@ -8423,10 +8421,7 @@ void PDFWriterImpl::writeJPG( JPGEmit& rObject )
{
BitmapEmit aEmit;
aEmit.m_nObject = nMaskObject;
- if (rObject.m_aMask.getPixelFormat() == vcl::PixelFormat::N1_BPP)
- aEmit.m_aBitmap = BitmapEx( rObject.m_aMask, rObject.m_aMask );
- else if(rObject.m_aMask.getPixelFormat() == vcl::PixelFormat::N8_BPP)
- aEmit.m_aBitmap = BitmapEx( rObject.m_aMask, AlphaMask( rObject.m_aMask ) );
+ aEmit.m_aBitmap = BitmapEx( rObject.m_aAlphaMask, rObject.m_aAlphaMask );
writeBitmapObject( aEmit, true );
}
@@ -8708,23 +8703,12 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask )
bWriteMask = true;
// else draw without alpha channel
}
- else
- {
- switch( rObject.m_aBitmap.GetTransparentType() )
- {
- case TransparentType::NONE:
- break;
- case TransparentType::Bitmap:
- bWriteMask = true;
- break;
- }
- }
}
else
{
if( m_aContext.Version < PDFWriter::PDFVersion::PDF_1_4 || ! rObject.m_aBitmap.IsAlpha() )
{
- aBitmap = getExportBitmap(rObject.m_aBitmap.GetMask());
+ aBitmap = getExportBitmap(rObject.m_aBitmap.GetAlpha());
aBitmap.Convert( BmpConversion::N1BitThreshold );
SAL_WARN_IF(aBitmap.getPixelFormat() != vcl::PixelFormat::N1_BPP, "vcl.pdfwriter", "mask conversion failed" );
}
@@ -9003,7 +8987,7 @@ void PDFWriterImpl::createEmbeddedFile(const Graphic& rGraphic, ReferenceXObject
rEmit.m_aPixelSize = rGraphic.GetPrefSize();
}
-void PDFWriterImpl::drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const Size& rSizePixel, const tools::Rectangle& rTargetArea, const Bitmap& rMask, const Graphic& rGraphic )
+void PDFWriterImpl::drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const Size& rSizePixel, const tools::Rectangle& rTargetArea, const AlphaMask& rAlphaMask, const Graphic& rGraphic )
{
MARK( "drawJPGBitmap" );
@@ -9023,10 +9007,10 @@ void PDFWriterImpl::drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const
// load stream to bitmap and draw the bitmap instead
Graphic aGraphic;
GraphicConverter::Import( rDCTData, aGraphic, ConvertDataFormat::JPG );
- if( !rMask.IsEmpty() && rMask.GetSizePixel() == aGraphic.GetSizePixel() )
+ if( !rAlphaMask.IsEmpty() && rAlphaMask.GetSizePixel() == aGraphic.GetSizePixel() )
{
Bitmap aBmp( aGraphic.GetBitmapEx().GetBitmap() );
- BitmapEx aBmpEx( aBmp, rMask );
+ BitmapEx aBmpEx( aBmp, rAlphaMask );
drawBitmap( rTargetArea.TopLeft(), rTargetArea.GetSize(), aBmpEx );
}
else
@@ -9043,8 +9027,8 @@ void PDFWriterImpl::drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const
aID.m_nSize = pStream->Tell();
pStream->Seek( STREAM_SEEK_TO_BEGIN );
aID.m_nChecksum = vcl_get_checksum( 0, pStream->GetData(), aID.m_nSize );
- if( ! rMask.IsEmpty() )
- aID.m_nMaskChecksum = rMask.GetChecksum();
+ if( ! rAlphaMask.IsEmpty() )
+ aID.m_nMaskChecksum = rAlphaMask.GetChecksum();
std::vector< JPGEmit >::const_iterator it = std::find_if(m_aJPGs.begin(), m_aJPGs.end(),
[&](const JPGEmit& arg) { return aID == arg.m_aID; });
@@ -9057,8 +9041,8 @@ void PDFWriterImpl::drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const
rEmit.m_aID = aID;
rEmit.m_pStream = std::move( pStream );
rEmit.m_bTrueColor = bIsTrueColor;
- if( !rMask.IsEmpty() && rMask.GetSizePixel() == rSizePixel )
- rEmit.m_aMask = rMask;
+ if( !rAlphaMask.IsEmpty() && rAlphaMask.GetSizePixel() == rSizePixel )
+ rEmit.m_aAlphaMask = rAlphaMask;
createEmbeddedFile(rGraphic, rEmit.m_aReferenceXObject, rEmit.m_nObject);
it = m_aJPGs.begin();
@@ -9140,12 +9124,6 @@ const BitmapEmit& PDFWriterImpl::createBitmapEmit( const BitmapEx& i_rBitmap, co
aID.m_nMaskChecksum = 0;
if( aBitmap.IsAlpha() )
aID.m_nMaskChecksum = aBitmap.GetAlpha().GetChecksum();
- else
- {
- Bitmap aMask = aBitmap.GetMask();
- if( ! aMask.IsEmpty() )
- aID.m_nMaskChecksum = aMask.GetChecksum();
- }
std::list< BitmapEmit >::const_iterator it = std::find_if(m_aBitmaps.begin(), m_aBitmaps.end(),
[&](const BitmapEmit& arg) { return aID == arg.m_aID; });
if( it == m_aBitmaps.end() )
@@ -9412,7 +9390,7 @@ void PDFWriterImpl::drawWallpaper( const tools::Rectangle& rRect, const Wallpape
bDrawBitmap = true;
}
- if( aBitmap.IsTransparent() )
+ if( aBitmap.IsAlpha() )
{
if( rWall.IsGradient() )
bDrawGradient = true;
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index 6280fc5ec11f..d49add8e8f71 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -230,7 +230,7 @@ struct JPGEmit
BitmapID m_aID;
std::unique_ptr<SvMemoryStream>
m_pStream;
- Bitmap m_aMask;
+ AlphaMask m_aAlphaMask;
sal_Int32 m_nObject;
bool m_bTrueColor;
ReferenceXObjectEmit m_aReferenceXObject;
@@ -1204,7 +1204,7 @@ public:
void drawBitmap( const Point& rDestPoint, const Size& rDestSize, const Bitmap& rBitmap, const Graphic& rGraphic );
void drawBitmap( const Point& rDestPoint, const Size& rDestSize, const BitmapEx& rBitmap );
- void drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const Size& rSizePixel, const tools::Rectangle& rTargetArea, const Bitmap& rMask, const Graphic& rGraphic );
+ void drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const Size& rSizePixel, const tools::Rectangle& rTargetArea, const AlphaMask& rAlphaMask, const Graphic& rGraphic );
/// Stores the original PDF data from rGraphic as an embedded file.
void createEmbeddedFile(const Graphic& rGraphic, ReferenceXObjectEmit& rEmit, sal_Int32 nBitmapObject);
diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index a0a4fb828995..878915e650c7 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -172,21 +172,21 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
bUseJPGCompression = false;
auto pStrm=std::make_shared<SvMemoryStream>();
- Bitmap aMask;
+ AlphaMask aAlphaMask;
bool bTrueColorJPG = true;
if ( bUseJPGCompression )
{
// TODO this checks could be done much earlier, saving us
// from trying conversion & stores before...
- if ( !aBitmapEx.IsTransparent() )
+ if ( !aBitmapEx.IsAlpha() )
{
const auto& rCacheEntry=m_aPDFBmpCache.find(
aBitmapEx.GetChecksum());
if ( rCacheEntry != m_aPDFBmpCache.end() )
{
m_rOuterFace.DrawJPGBitmap( *rCacheEntry->second, true, aSizePixel,
- tools::Rectangle( aPoint, aSize ), aMask, i_Graphic );
+ tools::Rectangle( aPoint, aSize ), aAlphaMask, i_Graphic );
return;
}
}
@@ -199,13 +199,8 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
WriteDIBBitmapEx(aBitmapEx, aTemp); // is capable of zlib stream compression
nZippedFileSize = aTemp.TellEnd();
}
- if ( aBitmapEx.IsTransparent() )
- {
- if ( aBitmapEx.IsAlpha() )
- aMask = aBitmapEx.GetAlpha().GetBitmap();
- else
- aMask = aBitmapEx.GetMask();
- }
+ if ( aBitmapEx.IsAlpha() )
+ aAlphaMask = aBitmapEx.GetAlpha();
Graphic aGraphic(BitmapEx(aBitmapEx.GetBitmap()));
Sequence< PropertyValue > aFilterData( 2 );
@@ -261,15 +256,15 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
}
if ( bUseJPGCompression )
{
- m_rOuterFace.DrawJPGBitmap( *pStrm, bTrueColorJPG, aSizePixel, tools::Rectangle( aPoint, aSize ), aMask, i_Graphic );
- if (!aBitmapEx.IsTransparent() && bTrueColorJPG)
+ m_rOuterFace.DrawJPGBitmap( *pStrm, bTrueColorJPG, aSizePixel, tools::Rectangle( aPoint, aSize ), aAlphaMask, i_Graphic );
+ if (!aBitmapEx.IsAlpha() && bTrueColorJPG)
{
// Cache last jpeg export
m_aPDFBmpCache.insert(
{aBitmapEx.GetChecksum(), pStrm});
}
}
- else if ( aBitmapEx.IsTransparent() )
+ else if ( aBitmapEx.IsAlpha() )
m_rOuterFace.DrawBitmapEx( aPoint, aSize, aBitmapEx );
else
m_rOuterFace.DrawBitmap( aPoint, aSize, aBitmapEx.GetBitmap(), i_Graphic );
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index e88592f225a5..d7928956e9bd 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -307,9 +307,8 @@ void Printer::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize,
}
else
{
- Bitmap aBmp( rBmpEx.GetBitmap() ), aMask( rBmpEx.GetMask() );
- aBmp.Replace( aMask, COL_WHITE );
- ImplPrintTransparent( aBmp, aMask, rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel );
+ Bitmap aBmp( rBmpEx.GetBitmap() );
+ ImplPrintTransparent( aBmp, Bitmap(), rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel );
}
}
diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx
index f7e4d8875341..3526d9017cb5 100644
--- a/vcl/source/gdi/print2.cxx
+++ b/vcl/source/gdi/print2.cxx
@@ -186,37 +186,7 @@ void ImplConvertTransparentAction( GDIMetaFile& o_rMtf,
}
Bitmap aBmp(aBmpEx.GetBitmap());
- if (!aBmpEx.IsAlpha())
- {
- // blend with mask
- Bitmap::ScopedReadAccess pRA(aBmp);
-
- if (!pRA)
- return; // what else should I do?
-
- Color aActualColor(aBgColor);
-
- if (pRA->HasPalette())
- aActualColor = pRA->GetBestPaletteColor(aBgColor);
-
- pRA.reset();
-
- // did we get true white?
- if (aActualColor.GetColorError(aBgColor))
- {
- // no, create truecolor bitmap, then
- aBmp.Convert(BmpConversion::N24Bit);
-
- // fill masked out areas white
- aBmp.Replace(aBmpEx.GetMask(), aBgColor);
- }
- else
- {
- // fill masked out areas white
- aBmp.Replace(aBmpEx.GetMask(), aActualColor);
- }
- }
- else
+ if (aBmpEx.IsAlpha())
{
// blend with alpha channel
aBmp.Convert(BmpConversion::N24Bit);
diff --git a/vcl/source/graphic/GraphicID.cxx b/vcl/source/graphic/GraphicID.cxx
index a27485da29aa..61cdee3c2ede 100644
--- a/vcl/source/graphic/GraphicID.cxx
+++ b/vcl/source/graphic/GraphicID.cxx
@@ -55,9 +55,7 @@ GraphicID::GraphicID(ImpGraphic const& rGraphic)
{
const BitmapEx aBmpEx(rGraphic.getBitmapEx(GraphicConversionParameters()));
- mnID1 |= (((static_cast<sal_uLong>(aBmpEx.GetTransparentType()) << 8)
- | (aBmpEx.IsAlpha() ? 1 : 0))
- & 0x0fffffff);
+ mnID1 |= aBmpEx.IsAlpha() ? 1 : 0;
mnID2 = aBmpEx.GetSizePixel().Width();
mnID3 = aBmpEx.GetSizePixel().Height();
mnID4 = rGraphic.getChecksum();
diff --git a/vcl/source/graphic/GraphicObject2.cxx b/vcl/source/graphic/GraphicObject2.cxx
index b9ac81baf1d1..e5b994f72b83 100644
--- a/vcl/source/graphic/GraphicObject2.cxx
+++ b/vcl/source/graphic/GraphicObject2.cxx
@@ -310,7 +310,7 @@ bool GraphicObject::ImplDrawTiled( OutputDevice* pOut, const tools::Rectangle& r
if( GetGraphic().IsAlpha() )
aAlphaGraphic.SetGraphic(BitmapEx(GetGraphic().GetBitmapEx().GetAlpha().GetBitmap()));
else
- aAlphaGraphic.SetGraphic(BitmapEx(GetGraphic().GetBitmapEx().GetMask()));
+ aAlphaGraphic.SetGraphic(BitmapEx(Bitmap()));
if( aAlphaGraphic.ImplRenderTempTile( *aVDev, nNumTilesInCacheX,
nNumTilesInCacheY, rSizePixel, pAttr ) )
@@ -455,17 +455,14 @@ void GraphicObject::ImplTransformBitmap( BitmapEx& rBmpEx,
BitmapEx aBmpEx2;
- if( rBmpEx.IsTransparent() )
+ if( rBmpEx.IsAlpha() )
{
- if( rBmpEx.IsAlpha() )
- aBmpEx2 = BitmapEx( rBmpEx.GetBitmap(), rBmpEx.GetAlpha() );
- else
- aBmpEx2 = BitmapEx( rBmpEx.GetBitmap(), rBmpEx.GetMask() );
+ aBmpEx2 = BitmapEx( rBmpEx.GetBitmap(), rBmpEx.GetAlpha() );
}
else
{
// #104115# Generate mask bitmap and init to zero
- Bitmap aMask(aBmpSize, vcl::PixelFormat::N1_BPP);
+ Bitmap aMask(aBmpSize, vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256));
aMask.Erase( Color(0,0,0) );
// #104115# Always generate transparent bitmap, we need the border transparent
diff --git a/vcl/source/graphic/UnoGraphic.cxx b/vcl/source/graphic/UnoGraphic.cxx
index eeda9d2a38c8..fa882a2c5917 100644
--- a/vcl/source/graphic/UnoGraphic.cxx
+++ b/vcl/source/graphic/UnoGraphic.cxx
@@ -171,7 +171,7 @@ uno::Sequence<sal_Int8> SAL_CALL Graphic::getMaskDIB()
{
SvMemoryStream aMemoryStream;
- WriteDIB(maGraphic.GetBitmapEx().GetMask(), aMemoryStream, false, true);
+ WriteDIB(maGraphic.GetBitmapEx().GetAlpha(), aMemoryStream, false, true);
return css::uno::Sequence<sal_Int8>( static_cast<sal_Int8 const *>(aMemoryStream.GetData()), aMemoryStream.Tell() );
}
else
diff --git a/vcl/source/graphic/UnoGraphicTransformer.cxx b/vcl/source/graphic/UnoGraphicTransformer.cxx
index 100e37b29a92..0edeaddb0213 100644
--- a/vcl/source/graphic/UnoGraphicTransformer.cxx
+++ b/vcl/source/graphic/UnoGraphicTransformer.cxx
@@ -59,7 +59,6 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
aGraphic.GetType() == GraphicType::GdiMetafile)
{
BitmapEx aBitmapEx(aGraphic.GetBitmapEx());
- Bitmap aBitmap(aBitmapEx.GetBitmap());
if (aBitmapEx.IsAlpha())
{
@@ -67,27 +66,11 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
aBitmapEx.Replace(aColorFrom, aColorTo, nTolerance);
aReturnGraphic = ::Graphic(aBitmapEx);
}
- else if (aBitmapEx.IsTransparent())
- {
- if (nAlphaTo == sal::static_int_cast< sal_Int8 >(0xff))
- {
- Bitmap aMask(aBitmapEx.GetMask());
- Bitmap aMask2(aBitmap.CreateMask(aColorFrom, nTolerance));
- aMask.CombineSimple(aMask2, BmpCombine::Or);
- aBitmap.Replace(aColorFrom, aColorTo, nTolerance);
- aReturnGraphic = ::Graphic(BitmapEx(aBitmap, aMask));
- }
- else
- {
- aBitmapEx.setAlphaFrom(cIndexFrom, 0xff - nAlphaTo);
- aBitmapEx.Replace(aColorFrom, aColorTo, nTolerance);
- aReturnGraphic = ::Graphic(aBitmapEx);
- }
- }
else
{
if ((nAlphaTo == 0) || (nAlphaTo == sal::static_int_cast< sal_Int8 >(0xff)))
{
+ Bitmap aBitmap(aBitmapEx.GetBitmap());
Bitmap aMask(aBitmap.CreateMask(aColorFrom, nTolerance));
aBitmap.Replace(aColorFrom, aColorTo, nTolerance);
aReturnGraphic = ::Graphic(BitmapEx(aBitmap, aMask));
diff --git a/vcl/source/helper/canvasbitmap.cxx b/vcl/source/helper/canvasbitmap.cxx
index 26f4bdb8e412..49faf0a73172 100644
--- a/vcl/source/helper/canvasbitmap.cxx
+++ b/vcl/source/helper/canvasbitmap.cxx
@@ -113,9 +113,9 @@ VclCanvasBitmap::VclCanvasBitmap( const BitmapEx& rBitmap ) :
m_nIndexIndex(-1),
m_bPalette(false)
{
- if( m_aBmpEx.IsTransparent() )
+ if( m_aBmpEx.IsAlpha() )
{
- m_aAlpha = m_aBmpEx.IsAlpha() ? m_aBmpEx.GetAlpha().GetBitmap() : m_aBmpEx.GetMask();
+ m_aAlpha = m_aBmpEx.GetAlpha().GetBitmap();
m_pAlphaAcc = Bitmap::ScopedReadAccess(m_aAlpha);
}
@@ -307,7 +307,7 @@ VclCanvasBitmap::VclCanvasBitmap( const BitmapEx& rBitmap ) :
}
m_nBitsPerOutputPixel = m_nBitsPerInputPixel;
- if( !m_aBmpEx.IsTransparent() )
+ if( !m_aBmpEx.IsAlpha() )
return;
// TODO(P1): need to interleave alpha with bitmap data -
@@ -353,7 +353,7 @@ geometry::IntegerSize2D SAL_CALL VclCanvasBitmap::getSize()
sal_Bool SAL_CALL VclCanvasBitmap::hasAlpha()
{
SolarMutexGuard aGuard;
- return m_aBmpEx.IsTransparent();
+ return m_aBmpEx.IsAlpha();
}
uno::Reference< rendering::XBitmap > SAL_CALL VclCanvasBitmap::getScaledBitmap( const geometry::RealSize2D& newSize,
@@ -381,7 +381,7 @@ uno::Sequence< sal_Int8 > SAL_CALL VclCanvasBitmap::getData( rendering::IntegerB
// Invalid/empty bitmap: no data available
if( !m_pBmpAcc )
throw lang::IndexOutOfBoundsException();
- if( m_aBmpEx.IsTransparent() && !m_pAlphaAcc )
+ if( m_aBmpEx.IsAlpha() && !m_pAlphaAcc )
throw lang::IndexOutOfBoundsException();
if( aRequestedArea.Left() < 0 || aRequestedArea.Top() < 0 ||
@@ -413,7 +413,7 @@ uno::Sequence< sal_Int8 > SAL_CALL VclCanvasBitmap::getData( rendering::IntegerB
nScanlineStride *= -1;
}
- if( !m_aBmpEx.IsTransparent() )
+ if( !m_aBmpEx.IsAlpha() )
{
OSL_ENSURE(m_pBmpAcc,"Invalid bmp read access");
@@ -481,7 +481,7 @@ uno::Sequence< sal_Int8 > SAL_CALL VclCanvasBitmap::getPixel( rendering::Integer
// Invalid/empty bitmap: no data available
if( !m_pBmpAcc )
throw lang::IndexOutOfBoundsException();
- if( m_aBmpEx.IsTransparent() && !m_pAlphaAcc )
+ if( m_aBmpEx.IsAlpha() && !m_pAlphaAcc )
throw lang::IndexOutOfBoundsException();
if( pos.X < 0 || pos.Y < 0 ||
@@ -499,7 +499,7 @@ uno::Sequence< sal_Int8 > SAL_CALL VclCanvasBitmap::getPixel( rendering::Integer
bitmapLayout.ScanLineStride= aRet.getLength();
const tools::Long nScanlineLeftOffset( pos.X*m_nBitsPerInputPixel/8 );
- if( !m_aBmpEx.IsTransparent() )
+ if( !m_aBmpEx.IsAlpha() )
{
assert(m_pBmpAcc && "Invalid bmp read access");
@@ -1052,7 +1052,7 @@ uno::Sequence<rendering::RGBColor> SAL_CALL VclCanvasBitmap::convertIntegerToRGB
ENSURE_OR_THROW(m_pBmpAcc,
"Unable to get BitmapAccess");
- if( m_aBmpEx.IsTransparent() )
+ if( m_aBmpEx.IsAlpha() )
{
const sal_Int32 nBytesPerPixel((m_nBitsPerOutputPixel+7)/8);
for( std::size_t i=0; i<nLen; i+=nBytesPerPixel )
@@ -1104,7 +1104,7 @@ uno::Sequence<rendering::ARGBColor> SAL_CALL VclCanvasBitmap::convertIntegerToAR
ENSURE_OR_THROW(m_pBmpAcc,
"Unable to get BitmapAccess");
- if( m_aBmpEx.IsTransparent() )
+ if( m_aBmpEx.IsAlpha() )
{
const tools::Long nNonAlphaBytes( (m_nBitsPerInputPixel+7)/8 );
const sal_Int32 nBytesPerPixel((m_nBitsPerOutputPixel+7)/8);
@@ -1159,7 +1159,7 @@ uno::Sequence<rendering::ARGBColor> SAL_CALL VclCanvasBitmap::convertIntegerToPA
ENSURE_OR_THROW(m_pBmpAcc,
"Unable to get BitmapAccess");
- if( m_aBmpEx.IsTransparent() )
+ if( m_aBmpEx.IsAlpha() )
{
const tools::Long nNonAlphaBytes( (m_nBitsPerInputPixel+7)/8 );
const sal_Int32 nBytesPerPixel((m_nBitsPerOutputPixel+7)/8);
@@ -1211,7 +1211,7 @@ uno::Sequence< ::sal_Int8 > SAL_CALL VclCanvasBitmap::convertIntegerFromRGB( con
uno::Sequence< sal_Int8 > aRes(nNumBytes);
sal_uInt8* pColors=reinterpret_cast<sal_uInt8*>(aRes.getArray());
- if( m_aBmpEx.IsTransparent() )
+ if( m_aBmpEx.IsAlpha() )
{
const tools::Long nNonAlphaBytes( (m_nBitsPerInputPixel+7)/8 );
for( std::size_t i=0; i<nLen; ++i )
@@ -1260,7 +1260,7 @@ uno::Sequence< ::sal_Int8 > SAL_CALL VclCanvasBitmap::convertIntegerFromARGB( co
uno::Sequence< sal_Int8 > aRes(nNumBytes);
sal_uInt8* pColors=reinterpret_cast<sal_uInt8*>(aRes.getArray());
- if( m_aBmpEx.IsTransparent() )
+ if( m_aBmpEx.IsAlpha() )
{
const tools::Long nNonAlphaBytes( (m_nBitsPerInputPixel+7)/8 );
for( std::size_t i=0; i<nLen; ++i )
@@ -1309,7 +1309,7 @@ uno::Sequence< ::sal_Int8 > SAL_CALL VclCanvasBitmap::convertIntegerFromPARGB( c
uno::Sequence< sal_Int8 > aRes(nNumBytes);
sal_uInt8* pColors=reinterpret_cast<sal_uInt8*>(aRes.getArray());
- if( m_aBmpEx.IsTransparent() )
+ if( m_aBmpEx.IsAlpha() )
{
const tools::Long nNonAlphaBytes( (m_nBitsPerInputPixel+7)/8 );
for( std::size_t i=0; i<nLen; ++i )
diff --git a/vcl/source/image/Image.cxx b/vcl/source/image/Image.cxx
index efcc46e41ea4..e32f7e54df22 100644
--- a/vcl/source/image/Image.cxx
+++ b/vcl/source/image/Image.cxx
@@ -142,7 +142,7 @@ void Image::Draw(OutputDevice* pOutDev, const Point& rPos, DrawImageFlags nStyle
if (nStyle & DrawImageFlags::SemiTransparent)
{
- if (aTempBitmapEx.IsTransparent())
+ if (aTempBitmapEx.IsAlpha())
{
Bitmap aAlphaBmp(aTempBitmapEx.GetAlpha().GetBitmap());
aAlphaBmp.Adjust(50);
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index db73c38dabdf..50533a5a40f3 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -264,7 +264,7 @@ void OutputDevice::DrawBitmapEx( const Point& rDestPt,
if( ImplIsRecordLayout() )
return;
- if( TransparentType::NONE == rBitmapEx.GetTransparentType() )
+ if( !rBitmapEx.IsAlpha() )
{
DrawBitmap( rDestPt, rBitmapEx.GetBitmap() );
}
@@ -283,7 +283,7 @@ void OutputDevice::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
if( ImplIsRecordLayout() )
return;
- if ( TransparentType::NONE == rBitmapEx.GetTransparentType() )
+ if ( !rBitmapEx.IsAlpha() )
{
DrawBitmap( rDestPt, rDestSize, rBitmapEx.GetBitmap() );
}
@@ -303,7 +303,7 @@ void OutputDevice::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
if( ImplIsRecordLayout() )
return;
- if( TransparentType::NONE == rBitmapEx.GetTransparentType() )
+ if( !rBitmapEx.IsAlpha() )
{
DrawBitmap( rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, rBitmapEx.GetBitmap() );
}
@@ -345,7 +345,7 @@ void OutputDevice::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
}
else
{
- aBmpEx = BitmapEx( aColorBmp, aBmpEx.GetMask() );
+ aBmpEx = BitmapEx( aColorBmp, aBmpEx.GetAlpha() );
}
}
else if( !aBmpEx.IsEmpty() )
@@ -531,7 +531,7 @@ void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize
rBitmapEx.Mirror(nMirrFlags);
const SalBitmap* pSalSrcBmp = rBitmapEx.ImplGetBitmapSalBitmap().get();
- std::shared_ptr<SalBitmap> xMaskBmp = rBitmapEx.ImplGetMaskSalBitmap();
+ std::shared_ptr<SalBitmap> xMaskBmp = rBitmapEx.maAlphaMask.ImplGetSalBitmap();
if (xMaskBmp)
{
@@ -615,8 +615,8 @@ void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize
if (mpAlphaVDev)
mpAlphaVDev->DrawBitmapEx(rDestPt,
rDestSize,
- BitmapEx(rBitmapEx.GetMask(),
- rBitmapEx.GetMask()));
+ BitmapEx(rBitmapEx.GetAlpha(),
+ rBitmapEx.GetAlpha()));
}
else
{
@@ -1066,16 +1066,9 @@ bool OutputDevice::DrawTransformBitmapExDirect(
SalBitmap* pSalSrcBmp = rBitmapEx.GetBitmap().ImplGetSalBitmap().get();
Bitmap aAlphaBitmap;
- if(rBitmapEx.IsTransparent())
+ if(rBitmapEx.IsAlpha())
{
- if(rBitmapEx.IsAlpha())
- {
- aAlphaBitmap = rBitmapEx.GetAlpha();
- }
- else
- {
- aAlphaBitmap = rBitmapEx.GetMask();
- }
+ aAlphaBitmap = rBitmapEx.GetAlpha();
}
else if (mpAlphaVDev)
{
@@ -1284,7 +1277,7 @@ void OutputDevice::DrawTransformedBitmapEx(
// Apply the alpha manually.
sal_uInt8 nColor( static_cast<sal_uInt8>( ::basegfx::fround( 255.0*(1.0 - fAlpha) + .5) ) );
AlphaMask aAlpha( bitmapEx.GetSizePixel(), &nColor );
- if( bitmapEx.IsTransparent())
+ if( bitmapEx.IsAlpha())
aAlpha.BlendWith( bitmapEx.GetAlpha());
bitmapEx = BitmapEx( bitmapEx.GetBitmap(), aAlpha );
}
@@ -1379,7 +1372,7 @@ void OutputDevice::DrawTransformedBitmapEx(
// #122923# when the result needs an alpha channel due to being rotated or sheared
// and thus uncovering areas, add these channels so that the own transformer (used
// in getTransformed) also creates a transformed alpha channel
- if(!aTransformed.IsTransparent() && (bSheared || bRotated))
+ if(!aTransformed.IsAlpha() && (bSheared || bRotated))
{
// parts will be uncovered, extend aTransformed with a mask bitmap
const Bitmap aContent(aTransformed.GetBitmap());
diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx
index c34e9fcf95e0..7fa966606744 100644
--- a/vcl/source/outdev/outdevstate.cxx
+++ b/vcl/source/outdev/outdevstate.cxx
@@ -468,17 +468,7 @@ void OutputDevice::SetBackground( const Wallpaper& rBackground )
if( bitmap.IsAlpha())
mpAlphaVDev->SetBackground( Wallpaper( BitmapEx( Bitmap( bitmap.GetAlpha()))));
else
- {
- switch( bitmap.GetTransparentType())
- {
- case TransparentType::NONE:
- mpAlphaVDev->SetBackground( Wallpaper( COL_BLACK ));
- break;
- case TransparentType::Bitmap:
- mpAlphaVDev->SetBackground( Wallpaper( BitmapEx( bitmap.GetMask())));
- break;
- }
- }
+ mpAlphaVDev->SetBackground( Wallpaper( COL_BLACK ));
}
else if( rBackground.IsGradient())
mpAlphaVDev->SetBackground( Wallpaper( COL_BLACK ));
diff --git a/vcl/source/outdev/wallpaper.cxx b/vcl/source/outdev/wallpaper.cxx
index 62258420ef5e..37f3b0c1bcd1 100644
--- a/vcl/source/outdev/wallpaper.cxx
+++ b/vcl/source/outdev/wallpaper.cxx
@@ -156,7 +156,7 @@ void OutputDevice::DrawBitmapWallpaper( tools::Long nX, tools::Long nY,
const tools::Long nBmpWidth = aBmpEx.GetSizePixel().Width();
const tools::Long nBmpHeight = aBmpEx.GetSizePixel().Height();
- const bool bTransparent = aBmpEx.IsTransparent();
+ const bool bTransparent = aBmpEx.IsAlpha();
// draw background
if( bTransparent )
@@ -222,7 +222,7 @@ void OutputDevice::DrawBitmapWallpaper( tools::Long nX, tools::Long nY,
aBmpEx = rWallpaper.GetBitmap();
aBmpEx.Scale( aSize );
- aBmpEx = BitmapEx( aBmpEx.GetBitmap().CreateDisplayBitmap( this ), aBmpEx.GetMask() );
+ aBmpEx = BitmapEx( aBmpEx.GetBitmap().CreateDisplayBitmap( this ), aBmpEx.GetAlpha() );
}
break;
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index f593e6d89a58..d5e1427e9af2 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -264,19 +264,7 @@ static void CreateNetWmAppIcon( sal_uInt16 nIcon, NetWmIconData& netwm_icon )
continue;
vcl::bitmap::convertBitmap32To24Plus8(aIcon, aIcon);
Bitmap icon = aIcon.GetBitmap();
- AlphaMask mask;
- switch( aIcon.GetTransparentType())
- {
- case TransparentType::NONE:
- {
- sal_uInt8 nTrans = 0;
- mask = AlphaMask( icon.GetSizePixel(), &nTrans );
- }
- break;
- case TransparentType::Bitmap:
- mask = aIcon.GetAlpha();
- break;
- }
+ AlphaMask mask = aIcon.GetAlpha();
BitmapReadAccess* iconData = icon.AcquireReadAccess();
BitmapReadAccess* maskData = mask.AcquireReadAccess();
netwm_icon[ pos++ ] = size; // width
@@ -340,7 +328,7 @@ static bool lcl_SelectAppIconPixmap( SalDisplay const *pDisplay, SalX11Screen nX
icon_mask = None;
- if( TransparentType::Bitmap == aIcon.GetTransparentType() )
+ if( aIcon.IsAlpha() )
{
icon_mask = XCreatePixmap( pDisplay->GetDisplay(),
pDisplay->GetRootWindow( pDisplay->GetDefaultXScreen() ),
@@ -353,7 +341,7 @@ static bool lcl_SelectAppIconPixmap( SalDisplay const *pDisplay, SalX11Screen nX
GC aMonoGC = XCreateGC( pDisplay->GetDisplay(), icon_mask,
GCFunction|GCForeground|GCBackground, &aValues );
- Bitmap aMask = aIcon.GetMask();
+ Bitmap aMask = aIcon.GetAlpha();
aMask.Invert();
X11SalBitmap *pMask = static_cast < X11SalBitmap * >
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 1a877bfa794a..d4a5defed4e6 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -1382,7 +1382,7 @@ public:
aAbove.Move(aSrc.GetSizePixel().Width(),0);
rDev.DrawBitmap(aAbove, aSrc.GetBitmap());
aAbove.Move(aSrc.GetSizePixel().Width(),0);
- rDev.DrawBitmap(aAbove, aSrc.GetMask());
+ rDev.DrawBitmap(aAbove, aSrc.GetAlpha());
// intermediates middle
BitmapEx aResult = AlphaRecovery(rDev, aLocation, aSrc);
@@ -1402,7 +1402,7 @@ public:
aBelow.Move(aGrey.GetSizePixel().Width(),0);
BitmapEx aGreyMask(aSrc.GetBitmap(),
- AlphaMask(aSrc.GetMask()));
+ aSrc.GetAlpha());
rDev.DrawBitmapEx(aBelow, aGreyMask);
aLocation.Move(aSrc.GetSizePixel().Width()*6,0);