summaryrefslogtreecommitdiff
path: root/vcl/source/outdev/transparent.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-08-17 00:48:18 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2020-08-17 07:57:24 +0200
commit4b1e208f3d94e4e1cf7c7eb951ceb4d023d5b7ce (patch)
treed1715f0081f4b7f707f400c823600c85a1dbb59a /vcl/source/outdev/transparent.cxx
parentd04c64d25929f08f9991535ecc8a33bdd31d395e (diff)
Use transparent buffer to correctly process transparency in metafiles
Otherwise the transparency gets converted into b&w mask here before applying the gradient. Required for tdf#134052. Change-Id: Ife00f75024f7d776fdb11e16fcafbd237f07eb04 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100830 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl/source/outdev/transparent.cxx')
-rw-r--r--vcl/source/outdev/transparent.cxx26
1 files changed, 6 insertions, 20 deletions
diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx
index 717e9584162a..f9da8c9975da 100644
--- a/vcl/source/outdev/transparent.cxx
+++ b/vcl/source/outdev/transparent.cxx
@@ -750,7 +750,8 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos,
if( !aDstRect.IsEmpty() )
{
- ScopedVclPtrInstance< VirtualDevice > xVDev;
+ // Create transparent buffer
+ ScopedVclPtrInstance<VirtualDevice> xVDev(DeviceFormat::DEFAULT, DeviceFormat::DEFAULT);
xVDev->mnDPIX = mnDPIX;
xVDev->mnDPIY = mnDPIY;
@@ -813,8 +814,6 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos,
}
else
{
- Bitmap aPaint, aMask;
- AlphaMask aAlpha;
MapMode aMap( GetMapMode() );
Point aOutPos( PixelToLogic( aDstRect.TopLeft() ) );
const bool bOldMap = mbMap;
@@ -828,20 +827,7 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos,
const_cast<GDIMetaFile&>(rMtf).Play( xVDev.get(), rPos, rSize );
const_cast<GDIMetaFile&>(rMtf).WindStart();
xVDev->EnableMapMode( false );
- aPaint = xVDev->GetBitmap( Point(), xVDev->GetOutputSizePixel() );
- xVDev->EnableMapMode( bVDevOldMap ); // #i35331#: MUST NOT use EnableMapMode( sal_True ) here!
-
- // create mask bitmap
- xVDev->SetLineColor( COL_BLACK );
- xVDev->SetFillColor( COL_BLACK );
- xVDev->DrawRect( tools::Rectangle( xVDev->PixelToLogic( Point() ), xVDev->GetOutputSize() ) );
- xVDev->SetDrawMode( DrawModeFlags::WhiteLine | DrawModeFlags::WhiteFill | DrawModeFlags::WhiteText |
- DrawModeFlags::WhiteBitmap | DrawModeFlags::WhiteGradient );
- const_cast<GDIMetaFile&>(rMtf).WindStart();
- const_cast<GDIMetaFile&>(rMtf).Play( xVDev.get(), rPos, rSize );
- const_cast<GDIMetaFile&>(rMtf).WindStart();
- xVDev->EnableMapMode( false );
- aMask = xVDev->GetBitmap( Point(), xVDev->GetOutputSizePixel() );
+ BitmapEx aPaint = xVDev->GetBitmapEx(Point(), xVDev->GetOutputSizePixel());
xVDev->EnableMapMode( bVDevOldMap ); // #i35331#: MUST NOT use EnableMapMode( sal_True ) here!
// create alpha mask from gradient
@@ -849,14 +835,14 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos,
xVDev->DrawGradient( tools::Rectangle( rPos, rSize ), rTransparenceGradient );
xVDev->SetDrawMode( DrawModeFlags::Default );
xVDev->EnableMapMode( false );
- xVDev->DrawMask( Point(), xVDev->GetOutputSizePixel(), aMask, COL_WHITE );
- aAlpha = xVDev->GetBitmap( Point(), xVDev->GetOutputSizePixel() );
+ AlphaMask aAlpha(xVDev->GetBitmap(Point(), xVDev->GetOutputSizePixel()));
+ aAlpha.BlendWith(aPaint.GetAlpha());
xVDev.disposeAndClear();
EnableMapMode( false );
- DrawBitmapEx( aDstRect.TopLeft(), BitmapEx( aPaint, aAlpha ) );
+ DrawBitmapEx(aDstRect.TopLeft(), BitmapEx(aPaint.GetBitmap(), aAlpha));
EnableMapMode( bOldMap );
}
}