diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-01-11 08:54:37 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-01-12 17:38:53 +0100 |
commit | d765ec2295d12ccde1fb25aa92c5d821de748add (patch) | |
tree | c2f806389478df23b78319c6043971f92995851c /drawinglayer | |
parent | a1d6701105456248f6ff39766a6699f26a8f3d60 (diff) |
transparency->alpha in tools::Color
this just changes the Get/Set methods, the constructor and internal
representation of Color is not changed.
Change-Id: Idb6e07cc08bbaa5bd55b6bd4b585e648aef507b6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109074
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/processor2d/vclpixelprocessor2d.cxx | 8 | ||||
-rw-r--r-- | drawinglayer/source/tools/emfphelperdata.cxx | 32 | ||||
-rw-r--r-- | drawinglayer/source/tools/emfpimageattributes.cxx | 2 |
3 files changed, 21 insertions, 21 deletions
diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 1402459297bb..143c9351a06a 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -869,7 +869,7 @@ void VclPixelProcessor2D::processBackgroundColorPrimitive2D( const basegfx::BColor aPolygonColor( maBColorModifierStack.getModifiedColor(rPrimitive.getBColor())); Color aFillColor(aPolygonColor); - aFillColor.SetTransparency(sal_uInt8((rPrimitive.getTransparency() * 255.0) + 0.5)); + aFillColor.SetAlpha(255 - sal_uInt8((rPrimitive.getTransparency() * 255.0) + 0.5)); mpOutputDevice->SetFillColor(aFillColor); mpOutputDevice->SetLineColor(); @@ -1034,7 +1034,7 @@ void VclPixelProcessor2D::processGlowPrimitive2D(const primitive2d::GlowPrimitiv // fades to both sides by the blur radius; thus blur radius is half of glow radius. const double fBlurRadius = aGlowRadiusVector.getLength() / 2; // Consider glow transparency (initial transparency near the object edge) - const sal_uInt8 nTransparency = rCandidate.getGlowColor().GetTransparency(); + const sal_uInt8 nAlpha = rCandidate.getGlowColor().GetAlpha(); impBufferDevice aBufferDevice(*mpOutputDevice, aRange); if (aBufferDevice.isVisible()) @@ -1061,8 +1061,8 @@ void VclPixelProcessor2D::processGlowPrimitive2D(const primitive2d::GlowPrimitiv BitmapEx bmpEx = mpOutputDevice->GetBitmapEx(aRect.TopLeft(), aRect.GetSize()); mpOutputDevice->SetAntialiasing(aPrevAA); - AlphaMask mask = ProcessAndBlurAlphaMask(bmpEx.GetAlpha(), fBlurRadius, fBlurRadius, - nTransparency); + AlphaMask mask + = ProcessAndBlurAlphaMask(bmpEx.GetAlpha(), fBlurRadius, fBlurRadius, 255 - nAlpha); // The end result is the bitmap filled with glow color and blurred 8-bit alpha mask const basegfx::BColor aGlowColor( diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index e8f0688d9cae..fb34dac496e2 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -588,7 +588,7 @@ namespace emfplushelper mrTargetHolders.Current().append( std::make_unique<drawinglayer::primitive2d::UnifiedTransparencePrimitive2D>( drawinglayer::primitive2d::Primitive2DContainer { aPrimitive }, - pen->GetColor().GetTransparency() / 255.0)); + (255 - pen->GetColor().GetAlpha()) / 255.0)); } if ((pen->penDataFlags & EmfPlusPenDataCustomStartCap) && (pen->customStartCap->polygon.begin()->count() > 1)) @@ -688,7 +688,7 @@ namespace emfplushelper void EmfPlusHelperData::EMFPPlusFillPolygonSolidColor(const ::basegfx::B2DPolyPolygon& polygon, Color const& color) { - if (color.GetTransparency() >= 255) + if (color.GetAlpha() == 0) return; if (!color.IsTransparent()) @@ -709,7 +709,7 @@ namespace emfplushelper mrTargetHolders.Current().append( std::make_unique<drawinglayer::primitive2d::UnifiedTransparencePrimitive2D>( drawinglayer::primitive2d::Primitive2DContainer { aPrimitive }, - color.GetTransparency() / 255.0)); + (255 - color.GetAlpha()) / 255.0)); } } @@ -840,8 +840,8 @@ namespace emfplushelper aColor.setGreen( aStartColor.getGreen() + brush->blendFactors[i] * ( aEndColor.getGreen() - aStartColor.getGreen() ) ); aColor.setBlue ( aStartColor.getBlue() + brush->blendFactors[i] * ( aEndColor.getBlue() - aStartColor.getBlue() ) ); aColor.setRed ( aStartColor.getRed() + brush->blendFactors[i] * ( aEndColor.getRed() - aStartColor.getRed() ) ); - const double aTransparency = brush->solidColor.GetTransparency() + brush->blendFactors[i] * ( brush->secondColor.GetTransparency() - brush->solidColor.GetTransparency() ); - aVector.emplace_back(aBlendPoint, aColor, (255.0 - aTransparency) / 255.0); + const double aAlpha = brush->solidColor.GetAlpha() + brush->blendFactors[i] * ( brush->secondColor.GetAlpha() - brush->solidColor.GetAlpha() ); + aVector.emplace_back(aBlendPoint, aColor, aAlpha / 255.0); } } else if (brush->colorblendPositions) @@ -863,20 +863,20 @@ namespace emfplushelper aBlendPoint = 2. * ( 1. - brush->colorblendPositions [i] ); } aColor = brush->colorblendColors[i].getBColor(); - aVector.emplace_back(aBlendPoint, aColor, (255 - brush->colorblendColors[i].GetTransparency()) / 255.0 ); + aVector.emplace_back(aBlendPoint, aColor, brush->colorblendColors[i].GetAlpha() / 255.0 ); } } else // ok, no extra points: just start and end { if (brush->type == BrushTypeLinearGradient) { - aVector.emplace_back(0.0, aStartColor, (255 - brush->solidColor.GetTransparency()) / 255.0); - aVector.emplace_back(1.0, aEndColor, (255 - brush->secondColor.GetTransparency()) / 255.0); + aVector.emplace_back(0.0, aStartColor, brush->solidColor.GetAlpha() / 255.0); + aVector.emplace_back(1.0, aEndColor, brush->secondColor.GetAlpha() / 255.0); } else // again, here reverse { - aVector.emplace_back(0.0, aEndColor, (255 - brush->secondColor.GetTransparency()) / 255.0); - aVector.emplace_back(1.0, aStartColor, (255 - brush->solidColor.GetTransparency()) / 255.0); + aVector.emplace_back(0.0, aEndColor, brush->secondColor.GetAlpha() / 255.0); + aVector.emplace_back(1.0, aStartColor, brush->solidColor.GetAlpha() / 255.0); } } @@ -1613,14 +1613,14 @@ namespace emfplushelper const basegfx::BColorModifier_gamma gamma(gammaVal); // gamma correct transparency color - sal_uInt16 alpha = uncorrectedColor.GetTransparency(); + sal_uInt16 alpha = uncorrectedColor.GetAlpha(); alpha = std::clamp(std::pow(alpha, 1.0 / gammaVal), 0.0, 1.0) * 255; basegfx::BColor modifiedColor(gamma.getModifiedColor(uncorrectedColor.getBColor())); color.SetRed(modifiedColor.getRed() * 255); color.SetGreen(modifiedColor.getGreen() * 255); color.SetBlue(modifiedColor.getBlue() * 255); - color.SetTransparency(alpha); + color.SetAlpha(alpha); } else { @@ -1630,7 +1630,7 @@ namespace emfplushelper mrPropertyHolders.Current().setTextColor(color.getBColor()); mrPropertyHolders.Current().setTextColorActive(true); - if (color.GetTransparency() < 255) + if (color.GetAlpha() > 0) { std::vector<double> emptyVector; drawinglayer::primitive2d::BasePrimitive2D* pBaseText = nullptr; @@ -1670,7 +1670,7 @@ namespace emfplushelper { aPrimitiveText = new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( drawinglayer::primitive2d::Primitive2DContainer { aPrimitiveText }, - color.GetTransparency() / 255.0); + (255 - color.GetAlpha()) / 255.0); } mrTargetHolders.Current().append( @@ -2116,7 +2116,7 @@ namespace emfplushelper ::basegfx::B2DPoint(charsPosX[pos], charsPosY[pos])); if (hasMatrix) transformMatrix *= transform; - if (color.GetTransparency() < 255) + if (color.GetAlpha() > 0) { drawinglayer::primitive2d::BasePrimitive2D* pBaseText = nullptr; if (font->Underline() || font->Strikeout()) @@ -2155,7 +2155,7 @@ namespace emfplushelper { aPrimitiveText = new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( drawinglayer::primitive2d::Primitive2DContainer { aPrimitiveText }, - color.GetTransparency() / 255.0); + (255 - color.GetAlpha()) / 255.0); } mrTargetHolders.Current().append( std::make_unique<drawinglayer::primitive2d::TransformPrimitive2D>( diff --git a/drawinglayer/source/tools/emfpimageattributes.cxx b/drawinglayer/source/tools/emfpimageattributes.cxx index 8508172fe6a5..1cb72b080ab8 100644 --- a/drawinglayer/source/tools/emfpimageattributes.cxx +++ b/drawinglayer/source/tools/emfpimageattributes.cxx @@ -56,7 +56,7 @@ void EMFPImageAttributes::Read(SvStream& s) clampColor.SetRed(clampColorRed); clampColor.SetGreen(clampColorGreen); clampColor.SetBlue(clampColorBlue); - clampColor.SetTransparency(clampColorAlpha); + clampColor.SetAlpha(255 - clampColorAlpha); SAL_INFO("drawinglayer", "EMF+\timage attributes"); SAL_WARN_IF((reserved1 != 0) || (reserved2 != 0), "drawinglayer", |