tdf#136787 Add control to create 1-bit B&W bitmap while creating mask.
Glow effect creates half transparent pixels on shadow. Creating 1-bit
B&W bitmap mask treates that half transparent pixels as black.
We control 1-bit B&W bitmap creation when we have half transparent
pixels.
Change-Id: Iaf298a0e5ffeeb6637fe5d3f56cf4f8e30a203e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134981
Tested-by: Jenkins
Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
(cherry picked from commit a658129012f1d183f95f8bf5dd6d7ff6926cd495)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135269
diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 139bb0b..53e75ac 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -982,11 +982,12 @@ namespace
nTransparency defines minimal transparency level.
*/
AlphaMask ProcessAndBlurAlphaMask(const Bitmap& rMask, double fErodeDilateRadius,
double fBlurRadius, sal_uInt8 nTransparency)
double fBlurRadius, sal_uInt8 nTransparency,
bool bConvertTo1Bit = true)
{
// Only completely white pixels on the initial mask must be considered for transparency. Any
// other color must be treated as black. This creates 1-bit B&W bitmap.
BitmapEx mask(rMask.CreateMask(COL_WHITE));
BitmapEx mask(bConvertTo1Bit ? rMask.CreateMask(COL_WHITE) : rMask);
// Scaling down increases performance without noticeable quality loss. Additionally,
// current blur implementation can only handle blur radius between 2 and 254.
@@ -1178,7 +1179,7 @@ void VclPixelProcessor2D::processShadowPrimitive2D(const primitive2d::ShadowPrim
BitmapEx bitmapEx = mpOutputDevice->GetBitmapEx(aRect.TopLeft(), aRect.GetSize());
AlphaMask mask = ProcessAndBlurAlphaMask(bitmapEx.GetAlpha(), 0, fBlurRadius, 0);
AlphaMask mask = ProcessAndBlurAlphaMask(bitmapEx.GetAlpha(), 0, fBlurRadius, 0, false);
const basegfx::BColor aShadowColor(
maBColorModifierStack.getModifiedColor(rCandidate.getShadowColor()));