diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-01-08 12:57:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-01-08 17:20:23 +0100 |
commit | 9cc41b9ad52e3da734ce72223946bd00bfc92d14 (patch) | |
tree | afb7874bb7be5bbb22dfd0f637fe1a362e9c0430 /drawinglayer/source/primitive2d/sceneprimitive2d.cxx | |
parent | e12e4dc835fcdd42b0966fd9dd02921654492ad8 (diff) |
opacity->alpha in BPixel
They are basically the same thing, but alpha is the preferred term
these days.
Also improve the mixing algorithm,
1 - opacity
is
255 - opacity
not
256 - opacity
since the range of sal_uInt8 is 0..255
Change-Id: I8788ac79285ab25c8d322b05817dffd3745fd699
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108963
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'drawinglayer/source/primitive2d/sceneprimitive2d.cxx')
-rw-r--r-- | drawinglayer/source/primitive2d/sceneprimitive2d.cxx | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx index e58c05e406af..fa35085e0f1f 100644 --- a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx @@ -61,7 +61,7 @@ namespace sal_uInt16 nRed(0); sal_uInt16 nGreen(0); sal_uInt16 nBlue(0); - sal_uInt16 nOpacity(0); + sal_uInt16 nAlpha(0); sal_uInt32 nIndex(rRaster.getIndexFromXY(x * mnAntiAlialize, y * mnAntiAlialize)); for(sal_uInt32 c(0); c < mnAntiAlialize; c++) @@ -69,21 +69,21 @@ namespace for(sal_uInt32 d(0); d < mnAntiAlialize; d++) { const basegfx::BPixel& rPixel(rRaster.getBPixel(nIndex++)); - nRed = nRed + rPixel.getRed(); - nGreen = nGreen + rPixel.getGreen(); - nBlue = nBlue + rPixel.getBlue(); - nOpacity = nOpacity + rPixel.getOpacity(); + nRed += rPixel.getRed(); + nGreen += rPixel.getGreen(); + nBlue += rPixel.getBlue(); + nAlpha += rPixel.getAlpha(); } nIndex += rRaster.getWidth() - mnAntiAlialize; } - nOpacity = nOpacity / nDivisor; + nAlpha /= nDivisor; - if(nOpacity) + if(nAlpha) { aContent.SetPixel(y, x, Color( - 255 - static_cast<sal_uInt8>(nOpacity), + 255 - static_cast<sal_uInt8>(nAlpha), static_cast<sal_uInt8>(nRed / nDivisor), static_cast<sal_uInt8>(nGreen / nDivisor), static_cast<sal_uInt8>(nBlue / nDivisor) )); @@ -103,9 +103,9 @@ namespace { const basegfx::BPixel& rPixel(rRaster.getBPixel(nIndex++)); - if(rPixel.getOpacity()) + if(rPixel.getAlpha()) { - aContent.SetPixel(y, x, Color(255 - rPixel.getOpacity(), rPixel.getRed(), rPixel.getGreen(), rPixel.getBlue())); + aContent.SetPixel(y, x, Color(255 - rPixel.getAlpha(), rPixel.getRed(), rPixel.getGreen(), rPixel.getBlue())); } else aContent.SetPixel(y, x, Color(255, 0, 0, 0)); |