diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-04-16 20:33:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-07-25 08:38:12 +0200 |
commit | 81994cb2b8b32453a92bcb011830fcb884f22ff3 (patch) | |
tree | ae1750e92421ad2e0ec3f50351c3be6581841598 /drawinglayer/source/primitive2d | |
parent | dabedcaf27b0af1e38a611b8d8e48444f848e01d (diff) |
Convert internal vcl bitmap formats transparency->alpha (II)
(Second attempt at landing this)
Image formats and graphics APIs use alpha, not transparency,
so change our internal formats and data structures to work directly
with alpha, so we don't need to modify data before we push it to
graphics APIs.
Add a couple of new Color constants to make the intention
of the vcl code clearer.
Notes
(*) On macOS, tweaking the logic in CreateWithSalBitmapAndMask
to more accurately reflect the requirements of the
CGImageCreateWithMask function seems to fix some
tests.
(*) The vcl code does not properly support gradients
with transparency. So the previous code was wrong, and this
change is going to result in slightly different wrongness.
Change-Id: I9e21c2e98d88ecfdc5f75db13bd1ffff7c38db98
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114168
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'drawinglayer/source/primitive2d')
-rw-r--r-- | drawinglayer/source/primitive2d/GlowSoftEgdeShadowTools.cxx | 6 | ||||
-rw-r--r-- | drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx | 1 |
2 files changed, 5 insertions, 2 deletions
diff --git a/drawinglayer/source/primitive2d/GlowSoftEgdeShadowTools.cxx b/drawinglayer/source/primitive2d/GlowSoftEgdeShadowTools.cxx index 3c45fdd030f4..9bbdf7176935 100644 --- a/drawinglayer/source/primitive2d/GlowSoftEgdeShadowTools.cxx +++ b/drawinglayer/source/primitive2d/GlowSoftEgdeShadowTools.cxx @@ -58,10 +58,10 @@ AlphaMask ProcessAndBlurAlphaMask(const Bitmap& rMask, double fErodeDilateRadius else if (fErodeDilateRadius < 0) BitmapFilter::Filter(mask, BitmapErodeFilter(-fErodeDilateRadius, 0xFF)); - if (nTransparency) + if (nTransparency != 255) { const Color aTransparency(nTransparency, nTransparency, nTransparency); - mask.Replace(COL_BLACK, aTransparency); + mask.Replace(COL_WHITE, aTransparency); } // We need 8-bit grey mask for blurring @@ -72,6 +72,8 @@ AlphaMask ProcessAndBlurAlphaMask(const Bitmap& rMask, double fErodeDilateRadius mask.Scale(rMask.GetSizePixel()); + mask.Invert(); // convert transparency to alpha + return AlphaMask(mask.GetBitmap()); } diff --git a/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx b/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx index 4a64da368a2f..89c4335bb0b3 100644 --- a/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx @@ -32,6 +32,7 @@ namespace drawinglayer::primitive2d DiscreteShadow::DiscreteShadow(const BitmapEx& rBitmapEx) : maBitmapEx(rBitmapEx) { + maBitmapEx.Invert(); // convert transparency to alpha const Size& rBitmapSize = getBitmapEx().GetSizePixel(); if(rBitmapSize.Width() != rBitmapSize.Height() || rBitmapSize.Width() < 7) |