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 | |
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>
67 files changed, 176 insertions, 181 deletions
diff --git a/canvas/source/cairo/cairo_canvashelper_text.cxx b/canvas/source/cairo/cairo_canvashelper_text.cxx index 4ee68f94de46..056ae519201f 100644 --- a/canvas/source/cairo/cairo_canvashelper_text.cxx +++ b/canvas/source/cairo/cairo_canvashelper_text.cxx @@ -135,8 +135,8 @@ namespace cairocanvas // extract alpha, and make color opaque // afterwards. Otherwise, OutputDevice won't draw anything - nTransparency = aColor.GetTransparency(); - aColor.SetTransparency(0); + nTransparency = 255 - aColor.GetAlpha(); + aColor.SetAlpha(255); rOutDev.SetTextColor( aColor ); diff --git a/canvas/source/directx/dx_textlayout_drawhelper.cxx b/canvas/source/directx/dx_textlayout_drawhelper.cxx index 312b72983b67..1ffeb612de3d 100644 --- a/canvas/source/directx/dx_textlayout_drawhelper.cxx +++ b/canvas/source/directx/dx_textlayout_drawhelper.cxx @@ -101,7 +101,7 @@ namespace dxcanvas aColor = vcl::unotools::doubleSequenceToColor( rRenderState.DeviceColor, mxGraphicDevice->getDeviceColorSpace()); - aColor.SetTransparency(0); + aColor.SetAlpha(255); xVirtualDevice->SetTextColor(aColor); // create the font diff --git a/canvas/source/vcl/canvasbitmaphelper.cxx b/canvas/source/vcl/canvasbitmaphelper.cxx index 336c12b83047..dd1898486e8a 100644 --- a/canvas/source/vcl/canvasbitmaphelper.cxx +++ b/canvas/source/vcl/canvasbitmaphelper.cxx @@ -148,7 +148,7 @@ namespace vclcanvas pRes[ 0 ] = aColor.GetRed(); pRes[ 1 ] = aColor.GetGreen(); pRes[ 2 ] = aColor.GetBlue(); - pRes[ 3 ] = aColor.GetTransparency(); + pRes[ 3 ] = 255 - aColor.GetAlpha(); return aRes; } diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx index 1f95b900592f..c3d31557c09d 100644 --- a/canvas/source/vcl/canvashelper.cxx +++ b/canvas/source/vcl/canvashelper.cxx @@ -479,7 +479,7 @@ namespace vclcanvas { tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDevProvider ); - const int nTransparency( setupOutDevState( viewState, renderState, FILL_COLOR ) ); + const int nAlpha( setupOutDevState( viewState, renderState, FILL_COLOR ) ); ::basegfx::B2DPolyPolygon aB2DPolyPoly( ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon)); aB2DPolyPoly.setClosed(true); // ensure closed poly, otherwise VCL does not fill @@ -487,13 +487,13 @@ namespace vclcanvas aB2DPolyPoly, viewState, renderState ) ); const bool bSourceAlpha( renderState.CompositeOperation == rendering::CompositeOperation::SOURCE ); - if( !nTransparency || bSourceAlpha ) + if( nAlpha == 255 || bSourceAlpha ) { mpOutDevProvider->getOutDev().DrawPolyPolygon( aPolyPoly ); } else { - const int nTransPercent( (nTransparency * 100 + 128) / 255 ); // normal rounding, no truncation here + const int nTransPercent( ((255 - nAlpha) * 100 + 128) / 255 ); // normal rounding, no truncation here mpOutDevProvider->getOutDev().DrawTransparent( aPolyPoly, static_cast<sal_uInt16>(nTransPercent) ); } @@ -503,7 +503,7 @@ namespace vclcanvas // actually what mp2ndOutDev is... well, here we do & // assume a 1bpp target - everything beyond 97% // transparency is fully transparent - if( nTransparency < 253 ) + if( nAlpha > 2 ) { mp2ndOutDevProvider->getOutDev().SetFillColor( COL_BLACK ); mp2ndOutDevProvider->getOutDev().DrawPolyPolygon( aPolyPoly ); @@ -1016,7 +1016,7 @@ namespace vclcanvas if( mp2ndOutDevProvider ) p2ndOutDev = &mp2ndOutDevProvider->getOutDev(); - int nTransparency(0); + int nAlpha(255); // TODO(P2): Don't change clipping all the time, maintain current clip // state and change only when update is necessary @@ -1032,8 +1032,8 @@ namespace vclcanvas // extract alpha, and make color opaque // afterwards. Otherwise, OutputDevice won't draw anything - nTransparency = aColor.GetTransparency(); - aColor.SetTransparency(0); + nAlpha = aColor.GetAlpha(); + aColor.SetAlpha(255); if( eColorType != IGNORE_COLOR ) { @@ -1075,7 +1075,7 @@ namespace vclcanvas } } - return nTransparency; + return nAlpha; } bool CanvasHelper::setupTextOutput( ::Point& o_rOutPos, diff --git a/canvas/source/vcl/canvashelper.hxx b/canvas/source/vcl/canvashelper.hxx index 48a6a2742431..ba385110bf71 100644 --- a/canvas/source/vcl/canvashelper.hxx +++ b/canvas/source/vcl/canvashelper.hxx @@ -262,7 +262,7 @@ namespace vclcanvas LINE_COLOR, FILL_COLOR, TEXT_COLOR, IGNORE_COLOR }; - // returns transparency of color + // returns alpha of color int setupOutDevState( const css::rendering::ViewState& viewState, const css::rendering::RenderState& renderState, ColorType eColorType ) const; diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index d9bb82e8c30c..bb628a9419e3 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -1130,7 +1130,7 @@ double VDataSeries::getValueByProperty( sal_Int32 nIndex, const OUString& rPropN sal_uInt8 r = aOldColor.GetRed() + (aColor.GetRed() - aOldColor.GetRed()) * mnPercent; sal_uInt8 g = aOldColor.GetGreen() + (aColor.GetGreen() - aOldColor.GetGreen()) * mnPercent; sal_uInt8 b = aOldColor.GetBlue() + (aColor.GetBlue() - aOldColor.GetBlue()) * mnPercent; - sal_uInt8 t = aOldColor.GetTransparency() + (aColor.GetTransparency() - aOldColor.GetTransparency()) * mnPercent; + sal_uInt8 t = 255 - (aOldColor.GetAlpha() + (aColor.GetAlpha() - aOldColor.GetAlpha()) * mnPercent); Color aRet(t, r, g, b); return sal_uInt32(aRet); } diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx index bf93f6bf2e3e..864450380f4e 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -92,7 +92,7 @@ namespace // force alpha part of color to // opaque. transparent painting is done // explicitly via MetaActionType::Transparent - aColor.SetTransparency(0); + aColor.SetAlpha(255); //aColor.SetTransparency(128); rColorSequence = vcl::unotools::colorToDoubleSequence( @@ -899,7 +899,7 @@ namespace cppcanvas::internal || (aTextColor.GetLuminance() < 8); aShadowColor = bIsDark ? COL_LIGHTGRAY : COL_BLACK; - aShadowColor.SetTransparency( aTextColor.GetTransparency() ); + aShadowColor.SetAlpha( aTextColor.GetAlpha() ); } if( rState.textReliefStyle != FontRelief::NONE ) @@ -935,7 +935,7 @@ namespace cppcanvas::internal if( aTextColor == COL_WHITE ) aReliefColor = COL_BLACK; - aReliefColor.SetTransparency( aTextColor.GetTransparency() ); + aReliefColor.SetAlpha( aTextColor.GetAlpha() ); } if (rState.isTextFillColorSet) @@ -1422,7 +1422,7 @@ namespace cppcanvas::internal // force alpha part of color to // opaque. transparent painting is done // explicitly via MetaActionType::Transparent - aColor.SetTransparency(0); + aColor.SetAlpha(255); rStates.getState().textColor = vcl::unotools::colorToDoubleSequence( diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx index 5751a9e8064f..a7e3dda42bc9 100644 --- a/cui/source/tabpages/chardlg.cxx +++ b/cui/source/tabpages/chardlg.cxx @@ -1545,13 +1545,13 @@ void SvxCharEffectsPage::ResetColor_Impl( const SfxItemSet& rSet ) Color aRGBColor = aColor; if (aRGBColor.IsTransparent() && aColor != COL_AUTO) { - aRGBColor.SetTransparency(0); + aRGBColor.SetAlpha(255); } m_xFontColorLB->SelectEntry(aRGBColor); if (m_xFontTransparencyMtr->get_visible() && aColor != COL_AUTO) { - double fTransparency = aColor.GetTransparency() * 100.0 / 255; + double fTransparency = (255 - aColor.GetAlpha()) * 100.0 / 255; m_xFontTransparencyMtr->set_value(basegfx::fround(fTransparency), FieldUnit::PERCENT); } @@ -1580,7 +1580,7 @@ bool SvxCharEffectsPage::FillItemSetColor_Impl( SfxItemSet& rSet ) { double fTransparency = m_xFontTransparencyMtr->get_value(FieldUnit::PERCENT) * 255.0 / 100; - aSelectedColor.SetTransparency(static_cast<sal_uInt8>(basegfx::fround(fTransparency))); + aSelectedColor.SetAlpha(255 - static_cast<sal_uInt8>(basegfx::fround(fTransparency))); } if (m_bOrigFontColor) diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx index 6eac86883c99..1956d0c8f86a 100644 --- a/cui/source/tabpages/tpcolor.cxx +++ b/cui/source/tabpages/tpcolor.cxx @@ -508,8 +508,8 @@ void SvxColorTabPage::ConvertColorValues (Color& rColor, ColorModel eModell) { case ColorModel::RGB: { - CmykToRgb_Impl (rColor, static_cast<sal_uInt16>(rColor.GetTransparency()) ); - rColor.SetTransparency (sal_uInt8(0)); + CmykToRgb_Impl (rColor, static_cast<sal_uInt16>(255 - rColor.GetAlpha()) ); + rColor.SetAlpha (255); } break; @@ -517,7 +517,7 @@ void SvxColorTabPage::ConvertColorValues (Color& rColor, ColorModel eModell) { sal_uInt16 nK; RgbToCmyk_Impl (rColor, nK ); - rColor.SetTransparency (static_cast<sal_uInt8>(nK)); + rColor.SetAlpha (255 - static_cast<sal_uInt8>(nK)); } break; } @@ -586,7 +586,7 @@ void SvxColorTabPage::UpdateColorValues( bool bUpdatePreset ) m_xCcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetRed() ), FieldUnit::PERCENT ); m_xMcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetBlue() ), FieldUnit::PERCENT ); m_xYcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetGreen() ), FieldUnit::PERCENT ); - m_xKcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetTransparency() ), FieldUnit::PERCENT ); + m_xKcustom->set_value( ColorToPercent_Impl( 255 - aCurrentColor.GetAlpha() ), FieldUnit::PERCENT ); if( bUpdatePreset ) { @@ -596,7 +596,7 @@ void SvxColorTabPage::UpdateColorValues( bool bUpdatePreset ) Application::GetSettings().GetUILanguageTag())); m_xYpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetGreen()), Application::GetSettings().GetUILanguageTag())); - m_xKpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetTransparency()), + m_xKpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(255 - aPreviousColor.GetAlpha()), Application::GetSettings().GetUILanguageTag())); } 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", diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx index 92d2afaf0bbb..6900e8cf8e1d 100644 --- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx +++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx @@ -1146,7 +1146,7 @@ namespace accessibility Color aColor( Application::GetSettings().GetStyleSettings().GetWindowColor() ); // the background is transparent - aColor.SetTransparency( 0xFF); + aColor.SetAlpha(0); return static_cast<sal_Int32>( aColor ); } diff --git a/editeng/source/accessibility/AccessibleImageBullet.cxx b/editeng/source/accessibility/AccessibleImageBullet.cxx index 0b319589f4d5..b75d3f32194d 100644 --- a/editeng/source/accessibility/AccessibleImageBullet.cxx +++ b/editeng/source/accessibility/AccessibleImageBullet.cxx @@ -340,7 +340,7 @@ namespace accessibility Color aColor( Application::GetSettings().GetStyleSettings().GetWindowColor() ); // the background is transparent - aColor.SetTransparency( 0xFF); + aColor.SetAlpha(0); return static_cast<sal_Int32>( aColor ); } diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index e3a6f8e5ac0c..e90f2f9586a3 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -1036,7 +1036,7 @@ bool SvxShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const aShadow.IsTransparent = aShadowColor.IsTransparent(); aShadow.Color = sal_Int32(aShadowColor); - sal_Int8 nTransparence = rtl::math::round(float(aShadowColor.GetTransparency() * 100) / 255); + sal_Int8 nTransparence = rtl::math::round((float(255 - aShadowColor.GetAlpha()) * 100) / 255); switch ( nMemberId ) { @@ -1085,7 +1085,7 @@ bool SvxShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) if ((rVal >>= nTransparence) && !o3tl::checked_multiply<sal_Int32>(nTransparence, 255, nTransparence)) { Color aColor(aShadow.Color); - aColor.SetTransparency(rtl::math::round(float(nTransparence) / 100)); + aColor.SetAlpha(255 - rtl::math::round(float(nTransparence) / 100)); aShadow.Color = sal_Int32(aColor); } break; @@ -2915,14 +2915,14 @@ bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const rVal <<= aColor.GetRGBColor(); break; case MID_BACK_COLOR_TRANSPARENCY: - rVal <<= SvxBrushItem::TransparencyToPercent(aColor.GetTransparency()); + rVal <<= SvxBrushItem::TransparencyToPercent(255 - aColor.GetAlpha()); break; case MID_GRAPHIC_POSITION: rVal <<= static_cast<style::GraphicLocation>(static_cast<sal_Int16>(eGraphicPos)); break; case MID_GRAPHIC_TRANSPARENT: - rVal <<= ( aColor.GetTransparency() == 0xff ); + rVal <<= ( aColor.GetAlpha() == 0 ); break; case MID_GRAPHIC_URL: @@ -2976,7 +2976,7 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) return false; if(MID_BACK_COLOR_R_G_B == nMemberId) { - aNewCol.SetTransparency(aColor.GetTransparency()); + aNewCol.SetAlpha(aColor.GetAlpha()); } aColor = aNewCol; } @@ -2986,7 +2986,7 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) sal_Int32 nTrans = 0; if ( !( rVal >>= nTrans ) || nTrans < 0 || nTrans > 100 ) return false; - aColor.SetTransparency(lcl_PercentToTransparency(nTrans)); + aColor.SetAlpha(255 - lcl_PercentToTransparency(nTrans)); } break; @@ -3005,7 +3005,7 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) break; case MID_GRAPHIC_TRANSPARENT: - aColor.SetTransparency( Any2Bool( rVal ) ? 0xff : 0 ); + aColor.SetAlpha( Any2Bool( rVal ) ? 0 : 255 ); break; case MID_GRAPHIC_URL: diff --git a/editeng/source/items/legacyitem.cxx b/editeng/source/items/legacyitem.cxx index 509c7a68b6aa..d630c4e5f0b3 100644 --- a/editeng/source/items/legacyitem.cxx +++ b/editeng/source/items/legacyitem.cxx @@ -802,7 +802,7 @@ namespace legacy aSerializer.readColor(aColor); aSerializer.readColor(aFillColor); rStrm.ReadSChar(nStyle); - aColor.SetTransparency(bTrans ? 0xff : 0); + aColor.SetAlpha(bTrans ? 0 : 255); rItem.SetLocation(static_cast<SvxShadowLocation>(cLoc)); rItem.SetWidth(_nWidth); diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index 5b931336426e..e83d08b35504 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -963,7 +963,7 @@ bool SvxTextLineItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const rVal <<= mColor; break; case MID_TL_HASCOLOR: - rVal <<= !mColor.GetTransparency(); + rVal <<= mColor.GetAlpha() == 255; break; } return true; @@ -997,14 +997,14 @@ bool SvxTextLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) { // Keep transparence, because it contains the information // whether the font color or the stored color should be used - sal_uInt8 nTrans = mColor.GetTransparency(); + sal_uInt8 nAlpha = mColor.GetAlpha(); mColor = Color( nCol ); - mColor.SetTransparency( nTrans ); + mColor.SetAlpha( nAlpha ); } } break; case MID_TL_HASCOLOR: - mColor.SetTransparency( Any2Bool( rVal ) ? 0 : 0xff ); + mColor.SetAlpha( Any2Bool( rVal ) ? 255 : 0 ); break; } return bRet; @@ -1339,7 +1339,7 @@ bool SvxBackgroundColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) c { case MID_GRAPHIC_TRANSPARENT: { - rVal <<= aColor.GetTransparency() == 0xff; + rVal <<= aColor.GetAlpha() == 0; break; } default: @@ -1361,7 +1361,7 @@ bool SvxBackgroundColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId { case MID_GRAPHIC_TRANSPARENT: { - aColor.SetTransparency( Any2Bool( rVal ) ? 0xff : 0 ); + aColor.SetAlpha( Any2Bool( rVal ) ? 0 : 255 ); SvxColorItem::SetValue( aColor ); break; } @@ -1407,7 +1407,7 @@ bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const { case MID_COLOR_ALPHA: { - auto fTransparency = static_cast<double>(mColor.GetTransparency()) * 100 / 255; + auto fTransparency = static_cast<double>(255 - mColor.GetAlpha()) * 100 / 255; rVal <<= static_cast<sal_Int16>(basegfx::fround(fTransparency)); break; } @@ -1432,7 +1432,7 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) if (bRet) { auto fTransparency = static_cast<double>(nTransparency) * 255 / 100; - mColor.SetTransparency(static_cast<sal_uInt8>(basegfx::fround(fTransparency))); + mColor.SetAlpha(255 - static_cast<sal_uInt8>(basegfx::fround(fTransparency))); } return bRet; } diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index c9b80e918ef1..9defa7812e67 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -160,7 +160,7 @@ double SVGAttributeWriter::ImplRound( double fValue ) void SVGAttributeWriter::ImplGetColorStr( const Color& rColor, OUString& rColorStr ) { - if( rColor.GetTransparency() == 255 ) + if( rColor.GetAlpha() == 0 ) rColorStr = "none"; else { @@ -178,8 +178,8 @@ void SVGAttributeWriter::AddColorAttr( const char* pColorAttrName, ImplGetColorStr( rColor, aColor ); - if( rColor.GetTransparency() > 0 && rColor.GetTransparency() < 255 ) - aColorOpacity = OUString::number( ImplRound( ( 255.0 - rColor.GetTransparency() ) / 255.0 ) ); + if( rColor.GetAlpha() < 255 && rColor.GetAlpha() > 0 ) + aColorOpacity = OUString::number( ImplRound( rColor.GetAlpha() / 255.0 ) ); mrExport.AddAttribute( XML_NAMESPACE_NONE, pColorAttrName, aColor ); @@ -3136,8 +3136,8 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, { Color aNewLineColor( mpVDev->GetLineColor() ), aNewFillColor( mpVDev->GetFillColor() ); - aNewLineColor.SetTransparency( sal::static_int_cast<sal_uInt8>( FRound( pA->GetTransparence() * 2.55 ) ) ); - aNewFillColor.SetTransparency( sal::static_int_cast<sal_uInt8>( FRound( pA->GetTransparence() * 2.55 ) ) ); + aNewLineColor.SetAlpha( 255 - sal::static_int_cast<sal_uInt8>( FRound( pA->GetTransparence() * 2.55 ) ) ); + aNewFillColor.SetAlpha( 255 - sal::static_int_cast<sal_uInt8>( FRound( pA->GetTransparence() * 2.55 ) ) ); maAttributeWriter.AddPaintAttr( aNewLineColor, aNewFillColor ); ImplWritePolyPolygon( rPolyPoly, false ); @@ -3248,7 +3248,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, mapCurShape->maShapePolyPoly = aShapePolyPoly; mapCurShape->maShapeFillColor = aFill.getFillColor(); - mapCurShape->maShapeFillColor.SetTransparency( static_cast<sal_uInt8>(FRound( 255.0 * aFill.getTransparency() )) ); + mapCurShape->maShapeFillColor.SetAlpha( 255 - static_cast<sal_uInt8>(FRound( 255.0 * aFill.getTransparency() )) ); if( bGradient ) { @@ -3338,7 +3338,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, } mapCurShape->maShapeLineColor = mpVDev->GetLineColor(); - mapCurShape->maShapeLineColor.SetTransparency( static_cast<sal_uInt8>(FRound( aStroke.getTransparency() * 255.0 )) ); + mapCurShape->maShapeLineColor.SetAlpha( 255 - static_cast<sal_uInt8>(FRound( aStroke.getTransparency() * 255.0 )) ); mapCurShape->mnStrokeWidth = FRound( aStroke.getStrokeWidth() ); aStroke.getDashArray( mapCurShape->maDashArray ); diff --git a/include/tools/color.hxx b/include/tools/color.hxx index fa062d59eddd..259cdc52f919 100644 --- a/include/tools/color.hxx +++ b/include/tools/color.hxx @@ -134,19 +134,19 @@ public: return B; } - /** Gets the transparency value. + /** Gets the alpha value. * @return A */ - sal_uInt8 GetTransparency() const + sal_uInt8 GetAlpha() const { - return A; + return 255 - A; } /** Is the color transparent? */ bool IsTransparent() const { - return GetTransparency() != 0; + return GetAlpha() != 255; } /** Is the color fully transparent i.e. 100% transparency ? @@ -180,12 +180,12 @@ public: B = nBlue; } - /** Sets the transparency value. - * @param nTransparency + /** Sets the alpha value. + * @param nAlpha */ - void SetTransparency(sal_uInt8 nTransparency) + void SetAlpha(sal_uInt8 nAlpha) { - A = nTransparency; + A = 255 - nAlpha; } /** Returns the same color but ignoring the transparency value. @@ -475,7 +475,7 @@ inline std::basic_ostream<charT, traits>& operator <<(std::basic_ostream<charT, << std::setw(2) << static_cast<int>(rColor.GetRed()) << std::setw(2) << static_cast<int>(rColor.GetGreen()) << std::setw(2) << static_cast<int>(rColor.GetBlue()) - << std::setw(2) << static_cast<int>(rColor.GetTransparency()) << "]"; + << std::setw(2) << static_cast<int>(rColor.GetAlpha()) << "]"; rStream.setf(nOrigFlags); return rStream; } diff --git a/include/vcl/RawBitmap.hxx b/include/vcl/RawBitmap.hxx index 7fac44a166af..79cef7c47e00 100644 --- a/include/vcl/RawBitmap.hxx +++ b/include/vcl/RawBitmap.hxx @@ -47,7 +47,7 @@ public: mpData[p++] = nColor.GetGreen(); mpData[p++] = nColor.GetBlue(); if (mnBitCount == 32) - mpData[p] = nColor.GetTransparency(); + mpData[p] = 255 - nColor.GetAlpha(); } Color GetPixel(tools::Long nY, tools::Long nX) const { diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index da3edf2169c7..c63e7d4181f1 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2035,7 +2035,7 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool // Automatic and Fixed. OOXML is setting automatic color, by not providing color. if( color != COL_AUTO ) { - color.SetTransparency(0); + color.SetAlpha(255); // TODO: special handle embossed/engraved WriteSolidFill(color, nTransparency); } diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index 5d8723d026ef..f02c37bee841 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -699,7 +699,7 @@ OUString XclXmlUtils::GetStreamName( const char* sStreamDir, const char* sStream OString XclXmlUtils::ToOString( const Color& rColor ) { char buf[9]; - sprintf( buf, "%.2X%.2X%.2X%.2X", 0xFF-rColor.GetTransparency(), rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue() ); + sprintf( buf, "%.2X%.2X%.2X%.2X", rColor.GetAlpha(), rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue() ); buf[8] = '\0'; return buf; } diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx index da5094ff23ff..b0402ada933a 100644 --- a/sc/source/filter/html/htmlexp.cxx +++ b/sc/source/filter/html/htmlexp.cxx @@ -976,7 +976,7 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SC ATTR_BACKGROUND, pCondItemSet ); Color aBgColor; - if ( rBrushItem.GetColor().GetTransparency() == 255 ) + if ( rBrushItem.GetColor().GetAlpha() == 0 ) aBgColor = aHTMLStyle.aBackgroundColor; // No unwanted background color else aBgColor = rBrushItem.GetColor(); diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 3d9ce033ff6a..b73b2fd0980b 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -713,7 +713,7 @@ static const SvxBrushItem* lcl_FindBackground( const ScDocument* pDoc, SCCOL nCo { // text goes to the right -> take background from the left while ( nCol > 0 && lcl_GetRotateDir( pDoc, nCol, nRow, nTab ) == nDir && - pBackground->GetColor().GetTransparency() != 255 ) + pBackground->GetColor().GetAlpha() != 0 ) { --nCol; pPattern = pDoc->GetPattern( nCol, nRow, nTab ); @@ -725,7 +725,7 @@ static const SvxBrushItem* lcl_FindBackground( const ScDocument* pDoc, SCCOL nCo { // text goes to the left -> take background from the right while ( nCol < pDoc->MaxCol() && lcl_GetRotateDir( pDoc, nCol, nRow, nTab ) == nDir && - pBackground->GetColor().GetTransparency() != 255 ) + pBackground->GetColor().GetAlpha() != 0 ) { ++nCol; pPattern = pDoc->GetPattern( nCol, nRow, nTab ); @@ -1626,7 +1626,7 @@ void ScOutputData::DrawRotatedFrame(vcl::RenderContext& rRenderContext) if (!pInfo->mxColorScale) { const Color& rColor = pBackground->GetColor(); - if (rColor.GetTransparency() != 255) + if (rColor.GetAlpha() != 0) { // draw background only for the changed row itself // (background doesn't extend into other cells). diff --git a/sd/source/filter/eppt/pptx-stylesheet.cxx b/sd/source/filter/eppt/pptx-stylesheet.cxx index 6acf110c50b2..27fc7f3ac598 100644 --- a/sd/source/filter/eppt/pptx-stylesheet.cxx +++ b/sd/source/filter/eppt/pptx-stylesheet.cxx @@ -113,7 +113,7 @@ void PPTExCharSheet::Write( SvStream& rSt, sal_uInt16 nLev, bool bSimpleText, aAny >>= bIsDark; nFontColor = bIsDark ? 0xffffff : 0x000000; } - nFontColor.SetTransparency(0xfe); + nFontColor.SetAlpha(1); if ( bSimpleText ) { rSt.WriteUInt16( rLev.mnFontHeight ) diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx index 8a413a7c706f..c34fa1bc78a6 100644 --- a/sd/source/filter/pdf/sdpdffilter.cxx +++ b/sd/source/filter/pdf/sdpdffilter.cxx @@ -159,7 +159,7 @@ bool SdPdfFilter::Import() else if (rPDFAnnotation.meSubType == vcl::pdf::PDFAnnotationSubType::Highlight) { if (!rCustomAnnotationMarker.maLineColor.IsTransparent()) - rCustomAnnotationMarker.maLineColor.SetTransparency(0x90); + rCustomAnnotationMarker.maLineColor.SetAlpha(255 - 0x90); auto* pMarker = static_cast<vcl::pdf::PDFAnnotationMarkerHighlight*>( rPDFAnnotation.mpMarker.get()); for (auto const& rPolygon : pMarker->maQuads) @@ -167,7 +167,7 @@ bool SdPdfFilter::Import() rCustomAnnotationMarker.mnLineWidth = 1; rCustomAnnotationMarker.maFillColor = rPDFAnnotation.maColor; if (!rCustomAnnotationMarker.maFillColor.IsTransparent()) - rCustomAnnotationMarker.maFillColor.SetTransparency(0x90); + rCustomAnnotationMarker.maFillColor.SetAlpha(255 - 0x90); } else if (rPDFAnnotation.meSubType == vcl::pdf::PDFAnnotationSubType::Line) { diff --git a/svx/source/accessibility/AccessibleShape.cxx b/svx/source/accessibility/AccessibleShape.cxx index 0780801cd3b0..074687dd6e0d 100644 --- a/svx/source/accessibility/AccessibleShape.cxx +++ b/svx/source/accessibility/AccessibleShape.cxx @@ -675,12 +675,12 @@ sal_Int32 SAL_CALL AccessibleShape::getBackground() Color crBk(nColor); if (nTrans == 0 ) { - crBk.SetTransparency(0xff); + crBk.SetAlpha(0); } else { nTrans = short(256 - nTrans / 100. * 256); - crBk.SetTransparency(sal_uInt8(nTrans)); + crBk.SetAlpha(255 - sal_uInt8(nTrans)); } nColor = crBk; } diff --git a/svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx b/svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx index 796fe0e2368a..ef973ecea8c8 100644 --- a/svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx @@ -143,7 +143,7 @@ drawinglayer::primitive2d::Primitive2DContainer ViewObjectContactOfPageBackgroun // init background with InitColor xRetval.resize(1); const basegfx::BColor aRGBColor(aInitColor.getBColor()); - xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::BackgroundColorPrimitive2D(aRGBColor, aInitColor.GetTransparency() / 255.0)); + xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::BackgroundColorPrimitive2D(aRGBColor, (255 - aInitColor.GetAlpha()) / 255.0)); } return xRetval; diff --git a/svx/source/sdr/overlay/overlaypolypolygon.cxx b/svx/source/sdr/overlay/overlaypolypolygon.cxx index 8abde414faa0..5be533074a50 100644 --- a/svx/source/sdr/overlay/overlaypolypolygon.cxx +++ b/svx/source/sdr/overlay/overlaypolypolygon.cxx @@ -53,13 +53,13 @@ namespace sdr::overlay auto aLine(new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(maLinePolyPolygon, aLineAttribute)); aReturnContainer = drawinglayer::primitive2d::Primitive2DContainer { aLine }; - if (maFillColor.GetTransparency() != 255) + if (maFillColor.GetAlpha() != 0) { auto aFill(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(maLinePolyPolygon, maFillColor.getBColor())); aReturnContainer.push_back(aFill); } - sal_uInt8 nTransparency = getBaseColor().GetTransparency(); + sal_uInt8 nTransparency = 255 - getBaseColor().GetAlpha(); if (nTransparency > 0) { const drawinglayer::primitive2d::Primitive2DReference aTransparencePrimitive( diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx index 5ee93efef85f..fc9154d42c6a 100644 --- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx +++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx @@ -219,7 +219,7 @@ namespace drawinglayer Color aColor(rSet.Get(SDRATTR_GLOW_COLOR).GetColorValue()); sal_uInt16 nTransparency(rSet.Get(SDRATTR_GLOW_TRANSPARENCY).GetValue()); if (nTransparency) - aColor.SetTransparency(std::round(nTransparency / 100.0 * 255.0)); + aColor.SetAlpha(255 - std::round(nTransparency / 100.0 * 255.0)); attribute::SdrGlowAttribute glowAttr{ nRadius, aColor }; return glowAttr; diff --git a/svx/source/sidebar/nbdtmg.cxx b/svx/source/sidebar/nbdtmg.cxx index 390b9cf20e3d..f786738902e0 100644 --- a/svx/source/sidebar/nbdtmg.cxx +++ b/svx/source/sidebar/nbdtmg.cxx @@ -194,7 +194,7 @@ void NBOTypeMgrBase::ImplLoad(const OUString& filename) if (aFmt.GetBulletFont()) { vcl::Font aFont(*aFmt.GetBulletFont()); Color c=aFont.GetColor(); - c.SetTransparency(0xFF); + c.SetAlpha(0); aFont.SetColor(c); aFmt.SetBulletFont(&aFont); aNum.SetLevel(i, aFmt); diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index 2661c98b72e5..fd53bf0e9d3d 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -363,7 +363,7 @@ namespace // Handle semi-transparent text for both the decorated and simple case here. pNewPrimitive = new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( drawinglayer::primitive2d::Primitive2DContainer{ pNewPrimitive }, - aFontColor.GetTransparency() / 255.0); + (255 - aFontColor.GetAlpha()) / 255.0); } if(rInfo.mbEndOfBullet) diff --git a/svx/source/unodraw/unobrushitemhelper.cxx b/svx/source/unodraw/unobrushitemhelper.cxx index 90168e42c8b3..d3dcf2680ec4 100644 --- a/svx/source/unodraw/unobrushitemhelper.cxx +++ b/svx/source/unodraw/unobrushitemhelper.cxx @@ -46,7 +46,7 @@ void setSvxBrushItemAsFillAttributesToTargetSet(const SvxBrushItem& rBrush, SfxI rToSet.ClearItem(a); } - const sal_uInt8 nTransparency(rBrush.GetColor().GetTransparency()); + const sal_uInt8 nTransparency(255 - rBrush.GetColor().GetAlpha()); // tdf#89478 check for image first if (GPOS_NONE != rBrush.GetGraphicPos()) @@ -181,7 +181,7 @@ static std::unique_ptr<SvxBrushItem> getSvxBrushItemForSolid(const SfxItemSet& r // since the oxff value is used for special purposes (like no fill and derive from parent) const sal_uInt8 aTargetTrans(std::min(sal_uInt8(0xfe), static_cast< sal_uInt8 >((nFillTransparence * 254) / 100))); - aFillColor.SetTransparency(aTargetTrans); + aFillColor.SetAlpha(255 - aTargetTrans); } return std::make_unique<SvxBrushItem>(aFillColor, nBackgroundID); @@ -200,7 +200,7 @@ std::unique_ptr<SvxBrushItem> getSvxBrushItemFromSourceSet(const SfxItemSet& rSo if (!bXMLImportHack && aFillColor != Color(0)) aFillColor = COL_AUTO; - aFillColor.SetTransparency(0xff); + aFillColor.SetAlpha(0); return std::make_unique<SvxBrushItem>(aFillColor, nBackgroundID); } @@ -241,7 +241,7 @@ std::unique_ptr<SvxBrushItem> getSvxBrushItemFromSourceSet(const SfxItemSet& rSo // since the oxff value is used for special purposes (like no fill and derive from parent) const sal_uInt8 aTargetTrans(std::min(sal_uInt8(0xfe), static_cast< sal_uInt8 >((nFillTransparence * 254) / 100))); - aMixedColor.SetTransparency(aTargetTrans); + aMixedColor.SetAlpha(255 - aTargetTrans); } aRetval = std::make_unique<SvxBrushItem>(aMixedColor, nBackgroundID); @@ -275,7 +275,7 @@ std::unique_ptr<SvxBrushItem> getSvxBrushItemFromSourceSet(const SfxItemSet& rSo // since the oxff value is used for special purposes (like no fill and derive from parent) const sal_uInt8 aTargetTrans(std::min(sal_uInt8(0xfe), static_cast< sal_uInt8 >((nFillTransparence * 254) / 100))); - aHatchColor.SetTransparency(aTargetTrans); + aHatchColor.SetAlpha(255 - aTargetTrans); aRetval = std::make_unique<SvxBrushItem>(aHatchColor, nBackgroundID); } diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx index ceb2bbe125d0..83ba3245dafe 100644 --- a/sw/qa/inc/swmodeltestbase.hxx +++ b/sw/qa/inc/swmodeltestbase.hxx @@ -429,7 +429,7 @@ inline std::ostream& operator<<(std::ostream& rStrm, const Color& rColor) rStrm << "Color: R:" << static_cast<int>(rColor.GetRed()) << " G:" << static_cast<int>(rColor.GetGreen()) << " B:" << static_cast<int>(rColor.GetBlue()) - << " A:" << static_cast<int>(rColor.GetTransparency()); + << " A:" << static_cast<int>(255 - rColor.GetAlpha()); return rStrm; } diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 27bfd520e03c..c1205226ea86 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -1571,7 +1571,7 @@ static void lcl_implDrawGraphicBackgrd( const SvxBrushItem& _rBackgrdBrush, /// background color is transparent --> draw transparent. { bDrawTransparent = true; - nTransparencyPercent = (aColor.GetTransparency()*100 + 0x7F)/0xFF; + nTransparencyPercent = ((255 - aColor.GetAlpha())*100 + 0x7F)/0xFF; } else if ( (_rGraphicObj.GetAttr().IsTransparent()) && (_rBackgrdBrush.GetColor() == COL_TRANSPARENT) ) @@ -2107,7 +2107,7 @@ void DrawGraphic( // the transparency value is taken from the background graphic, // otherwise take the transparency value from the color. sal_Int8 nTransparencyPercent = static_cast<sal_Int8>( - (( bTransparentGrfWithNoFillBackgrd ? nGrfTransparency : aColor.GetTransparency() + (( bTransparentGrfWithNoFillBackgrd ? nGrfTransparency : (255 - aColor.GetAlpha()) )*100 + 0x7F)/0xFF); // draw poly-polygon transparent pOutDev->DrawTransparent( aDrawPoly, nTransparencyPercent ); @@ -7303,7 +7303,7 @@ bool SwFrame::GetBackgroundBrush( bNewDrawingLayerFillStyleIsUsedAndNotNoFill || // done when SvxBrushItem is used - !rBack.GetColor().GetTransparency() || rBack.GetGraphicPos() != GPOS_NONE || + rBack.GetColor().GetAlpha() == 255 || rBack.GetGraphicPos() != GPOS_NONE || // done when direct color is forced rxCol || diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 8ff2aac8d8da..b2d5bfa28728 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -602,7 +602,7 @@ SwTransparentTextGuard::~SwTransparentTextGuard() m_aContentMetafile.SetPrefSize(m_aPorRect.SSize()); m_rDrawInf.SetOut(*m_rPaintInf.GetOut()); Gradient aVCLGradient; - sal_uInt8 nTransPercentVcl = m_rPaintInf.GetFont()->GetColor().GetTransparency(); + sal_uInt8 nTransPercentVcl = 255 - m_rPaintInf.GetFont()->GetColor().GetAlpha(); const Color aTransColor(nTransPercentVcl, nTransPercentVcl, nTransPercentVcl); aVCLGradient.SetStyle(GradientStyle::Linear); aVCLGradient.SetStartColor(aTransColor); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index e5b068a11676..29da55150a6a 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -7444,7 +7444,7 @@ void DocxAttributeOutput::CharColor( const SvxColorItem& rColor ) } AddToAttrList( m_pColorAttrList, FSNS( XML_w, XML_val ), aColorString.getStr() ); - m_nCharTransparence = aColor.GetTransparency(); + m_nCharTransparence = 255 - aColor.GetAlpha(); } void DocxAttributeOutput::CharContour( const SvxContourItem& rContour ) @@ -9038,7 +9038,7 @@ void DocxAttributeOutput::FormatAnchor( const SwFormatAnchor& ) static std::optional<sal_Int32> lcl_getDmlAlpha(const SvxBrushItem& rBrush) { std::optional<sal_Int32> oRet; - sal_Int32 nTransparency = rBrush.GetColor().GetTransparency(); + sal_Int32 nTransparency = 255 - rBrush.GetColor().GetAlpha(); if (nTransparency) { // Convert transparency to percent diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 1ed60de45e25..1af1dce13942 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -1083,7 +1083,7 @@ static OString lcl_TransparencyToDrawingMlAlpha(const Color& rColor) { if (rColor.IsTransparent()) { - sal_Int32 nAlphaPercent = 100 - float(rColor.GetTransparency()) / 2.55; + sal_Int32 nAlphaPercent = float(rColor.GetAlpha()) / 2.55; return OString::number(nAlphaPercent * oox::drawingml::PER_PERCENT); } diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 8b514baa59a4..48bf34fc9881 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -1869,7 +1869,7 @@ void SwBasicEscherEx::WriteBrushAttr(const SvxBrushItem &rBrush, rPropOpt.AddOpt( ESCHER_Prop_fillBackColor, nFillColor ^ 0xffffff ); rPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x100010 ); - nOpaque = rBrush.GetColor().GetTransparency(); + nOpaque = 255 - rBrush.GetColor().GetAlpha(); if (0 != nOpaque) bSetOpacity = true; } diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index de8a1866ba36..c04770c53f3c 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -1838,7 +1838,7 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject const * pSdrObj, sal_uInt16 nRes = WW8ITEMVALUE(rOldSet, XATTR_FILLTRANSPARENCE, XFillTransparenceItem); nTrans = sal_uInt8((nRes * 0xFE) / 100); - aBrushItem.GetColor().SetTransparency(nTrans); + aBrushItem.GetColor().SetAlpha(255 - nTrans); bBrushItemOk = true; } @@ -1855,7 +1855,7 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject const * pSdrObj, // Writer graphics don't have it yet if (eShapeType != mso_sptPictureFrame) { - aBrushItem.GetColor().SetTransparency(0xFE); + aBrushItem.GetColor().SetAlpha(1); bBrushItemOk = true; } break; @@ -1867,7 +1867,7 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject const * pSdrObj, aBrushItem.SetColor(aColor); if (bBrushItemOk) // has trans - aBrushItem.GetColor().SetTransparency(nTrans); + aBrushItem.GetColor().SetAlpha(255 - nTrans); bBrushItemOk = true; } diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 75289e386eb4..762ea0c81869 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -3605,7 +3605,7 @@ void SwWW8ImplReader::Read_TextForeColor(sal_uInt16, const sal_uInt8* pData, sho // At least when transparency is 0xff and the color is black, Word renders that as black. if (aColor.IsTransparent() && aColor != COL_AUTO) { - aColor.SetTransparency(0); + aColor.SetAlpha(255); } NewAttr(SvxColorItem(aColor, RES_CHRATR_COLOR)); diff --git a/sw/source/filter/xml/xmlimpit.cxx b/sw/source/filter/xml/xmlimpit.cxx index f41cec7cd206..2d0ea2bc046d 100644 --- a/sw/source/filter/xml/xmlimpit.cxx +++ b/sw/source/filter/xml/xmlimpit.cxx @@ -700,13 +700,13 @@ bool SvXMLImportItemMapper::PutXMLValue( case MID_BACK_COLOR: if( IsXMLToken( rValue, XML_TRANSPARENT ) ) { - rBrush.GetColor().SetTransparency(0xff); + rBrush.GetColor().SetAlpha(0); bOk = true; } else if (::sax::Converter::convertColor(nTempColor, rValue)) { Color aTempColor(nTempColor); - aTempColor.SetTransparency(0); + aTempColor.SetAlpha(255); rBrush.SetColor( aTempColor ); bOk = true; } diff --git a/tools/qa/cppunit/test_color.cxx b/tools/qa/cppunit/test_color.cxx index 8ba4ea5839ed..567aac90a03c 100644 --- a/tools/qa/cppunit/test_color.cxx +++ b/tools/qa/cppunit/test_color.cxx @@ -63,7 +63,7 @@ void Test::testVariables() aColor.B = 0x44; CPPUNIT_ASSERT_EQUAL(int(0x11223344), int(aColor.mValue)); - aColor.SetTransparency(0x77); + aColor.SetAlpha(255 - 0x77); CPPUNIT_ASSERT_EQUAL(int(0x77223344), int(aColor.mValue)); aColor.SetRed(0x88); diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 825da3e5f415..4bbd6f76ec5c 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -2009,7 +2009,7 @@ bool SvpSalGraphics::implDrawGradient(basegfx::B2DPolyPolygon const & rPolyPolyg double r = rStop.maColor.GetRed() / 255.0; double g = rStop.maColor.GetGreen() / 255.0; double b = rStop.maColor.GetBlue() / 255.0; - double a = (0xFF - rStop.maColor.GetTransparency()) / 255.0; + double a = rStop.maColor.GetAlpha() / 255.0; double offset = rStop.mfOffset; cairo_pattern_add_color_stop_rgba(pattern, offset, r, g, b, a); diff --git a/vcl/inc/bitmap/ScanlineTools.hxx b/vcl/inc/bitmap/ScanlineTools.hxx index 9528f48090e9..1e3ab5023638 100644 --- a/vcl/inc/bitmap/ScanlineTools.hxx +++ b/vcl/inc/bitmap/ScanlineTools.hxx @@ -46,7 +46,7 @@ public: virtual void writePixel(Color nColor) override { - *pData++ = nColor.GetTransparency(); + *pData++ = 255 - nColor.GetAlpha(); *pData++ = nColor.GetRed(); *pData++ = nColor.GetGreen(); *pData++ = nColor.GetBlue(); diff --git a/vcl/inc/qt5/Qt5Tools.hxx b/vcl/inc/qt5/Qt5Tools.hxx index 1110c7099d80..b7e4089e6f52 100644 --- a/vcl/inc/qt5/Qt5Tools.hxx +++ b/vcl/inc/qt5/Qt5Tools.hxx @@ -79,8 +79,7 @@ inline Point toPoint(const QPoint& rPoint) { return Point(rPoint.x(), rPoint.y() inline QColor toQColor(const Color& rColor) { - return QColor(rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue(), - 255 - rColor.GetTransparency()); + return QColor(rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue(), rColor.GetAlpha()); } Qt::DropActions toQtDropActions(sal_Int8 dragOperation); diff --git a/vcl/qa/cppunit/BackendTest.cxx b/vcl/qa/cppunit/BackendTest.cxx index 6e171754a225..4a32a50b6a92 100644 --- a/vcl/qa/cppunit/BackendTest.cxx +++ b/vcl/qa/cppunit/BackendTest.cxx @@ -584,9 +584,9 @@ public: device->SetBackground(Wallpaper(COL_TRANSPARENT)); device->Erase(); exportDevice("/tmp/12-07_erase.png", device); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(255), device->GetPixel(Point(0, 0)).GetTransparency()); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(255), device->GetPixel(Point(9, 9)).GetTransparency()); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(255), device->GetPixel(Point(5, 5)).GetTransparency()); + CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), device->GetPixel(Point(0, 0)).GetAlpha()); + CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), device->GetPixel(Point(9, 9)).GetAlpha()); + CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), device->GetPixel(Point(5, 5)).GetAlpha()); } } diff --git a/vcl/qa/cppunit/BitmapScaleTest.cxx b/vcl/qa/cppunit/BitmapScaleTest.cxx index 285799e2da52..09ec8f9a3728 100644 --- a/vcl/qa/cppunit/BitmapScaleTest.cxx +++ b/vcl/qa/cppunit/BitmapScaleTest.cxx @@ -64,7 +64,7 @@ void assertColorsAreSimilar(int maxDifference, const std::string& message, if (abs(expected.GetRed() - actual.GetRed()) <= maxDifference && abs(expected.GetGreen() - actual.GetGreen()) <= maxDifference && abs(expected.GetBlue() - actual.GetBlue()) <= maxDifference - && abs(expected.GetTransparency() - actual.GetTransparency()) <= maxDifference) + && abs(expected.GetAlpha() - actual.GetAlpha()) <= maxDifference) { return; } diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx index c2f2b592309f..56395358863b 100644 --- a/vcl/qa/cppunit/BitmapTest.cxx +++ b/vcl/qa/cppunit/BitmapTest.cxx @@ -73,7 +73,7 @@ void assertColorsAreSimilar(int maxDifference, const std::string& message, if (abs(expected.GetRed() - actual.GetRed()) <= maxDifference && abs(expected.GetGreen() - actual.GetGreen()) <= maxDifference && abs(expected.GetBlue() - actual.GetBlue()) <= maxDifference - && abs(expected.GetTransparency() - actual.GetTransparency()) <= maxDifference) + && abs(expected.GetAlpha() - actual.GetAlpha()) <= maxDifference) { return; } diff --git a/vcl/qa/cppunit/bitmapcolor.cxx b/vcl/qa/cppunit/bitmapcolor.cxx index 58d889a3d8a5..7329564d46c4 100644 --- a/vcl/qa/cppunit/bitmapcolor.cxx +++ b/vcl/qa/cppunit/bitmapcolor.cxx @@ -56,8 +56,8 @@ void BitmapColorTest::defaultConstructor() CPPUNIT_ASSERT_EQUAL_MESSAGE("Red wrong", static_cast<sal_uInt8>(0), aBmpColor.GetRed()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(0), aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(0), - aBmpColor.GetTransparency()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(255), + aBmpColor.GetAlpha()); } void BitmapColorTest::colorValueConstructor() @@ -69,8 +69,8 @@ void BitmapColorTest::colorValueConstructor() CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(0), aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(0), - aBmpColor.GetTransparency()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(255), + aBmpColor.GetAlpha()); } { @@ -81,8 +81,8 @@ void BitmapColorTest::colorValueConstructor() aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(128), aBmpColor.GetBlue()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(0), - aBmpColor.GetTransparency()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(255), + aBmpColor.GetAlpha()); } { @@ -93,8 +93,8 @@ void BitmapColorTest::colorValueConstructor() aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(255), aBmpColor.GetBlue()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(0), - aBmpColor.GetTransparency()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(255), + aBmpColor.GetAlpha()); } } @@ -107,8 +107,8 @@ void BitmapColorTest::colorClassConstructor() CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(0), aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(0), - aBmpColor.GetTransparency()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(255), + aBmpColor.GetAlpha()); } { @@ -119,8 +119,8 @@ void BitmapColorTest::colorClassConstructor() aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(127), aBmpColor.GetBlue()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(0), - aBmpColor.GetTransparency()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(255), + aBmpColor.GetAlpha()); } { @@ -131,8 +131,8 @@ void BitmapColorTest::colorClassConstructor() aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(255), aBmpColor.GetBlue()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(0), - aBmpColor.GetTransparency()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(255), + aBmpColor.GetAlpha()); } // Transparency / Alpha @@ -143,8 +143,8 @@ void BitmapColorTest::colorClassConstructor() CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(64), aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(255), - aBmpColor.GetTransparency()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparency wrong", static_cast<sal_uInt8>(0), + aBmpColor.GetAlpha()); } } diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index a93d42f77ca9..b55d4856fbee 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -49,7 +49,7 @@ static std::ostream& operator<<(std::ostream& rStrm, const Color& rColor) rStrm << "Color: R:" << static_cast<int>(rColor.GetRed()) << " G:" << static_cast<int>(rColor.GetGreen()) << " B:" << static_cast<int>(rColor.GetBlue()) - << " A:" << static_cast<int>(rColor.GetTransparency()); + << " A:" << static_cast<int>(255 - rColor.GetAlpha()); return rStrm; } diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 9e7a441d3b86..8266fe938bbf 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -200,8 +200,7 @@ bool polygonContainsLine(const basegfx::B2DPolyPolygon& rPolyPolygon) SkColor toSkColor(Color color) { - return SkColorSetARGB(255 - color.GetTransparency(), color.GetRed(), color.GetGreen(), - color.GetBlue()); + return SkColorSetARGB(color.GetAlpha(), color.GetRed(), color.GetGreen(), color.GetBlue()); } SkColor toSkColorWithTransparency(Color aColor, double fTransparency) @@ -211,7 +210,7 @@ SkColor toSkColorWithTransparency(Color aColor, double fTransparency) SkColor toSkColorWithIntensity(Color color, int intensity) { - return SkColorSetARGB(255 - color.GetTransparency(), color.GetRed() * intensity / 100, + return SkColorSetARGB(color.GetAlpha(), color.GetRed() * intensity / 100, color.GetGreen() * intensity / 100, color.GetBlue() * intensity / 100); } diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx index 18b10680eeb8..77bb784241f0 100644 --- a/vcl/skia/salbmp.cxx +++ b/vcl/skia/salbmp.cxx @@ -627,8 +627,7 @@ SkBitmap SkiaSalBitmap::GetAsSkBitmap() const static SkColor toSkColor(Color color) { - return SkColorSetARGB(255 - color.GetTransparency(), color.GetRed(), color.GetGreen(), - color.GetBlue()); + return SkColorSetARGB(color.GetAlpha(), color.GetRed(), color.GetGreen(), color.GetBlue()); } // If mEraseColor is set, this is the color to use when the bitmap is used as alpha bitmap. @@ -1230,7 +1229,7 @@ OString SkiaSalBitmap::GetImageKey() const if (mEraseColorSet) { std::stringstream ss; - ss << std::hex << std::setfill('0') << std::setw(2) << (255 - mEraseColor.GetTransparency()) + ss << std::hex << std::setfill('0') << std::setw(2) << mEraseColor.GetAlpha() << std::setw(6) << sal_uInt32(mEraseColor.GetRGBColor()); return OStringLiteral("E") + ss.str().c_str(); } diff --git a/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx b/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx index 0544943b3417..f3b371e03f1c 100644 --- a/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx +++ b/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx @@ -107,7 +107,7 @@ template <typename MorphologyOp> struct Value<MorphologyOp, 0> sal_uInt8* /*pHint*/ = nullptr) { const auto& rSource = pReadAccess->GetColor(y, x); - aResult = Color(MorphologyOp::apply(rSource.GetTransparency(), aResult.GetTransparency()), + aResult = Color(255 - MorphologyOp::apply(rSource.GetAlpha(), aResult.GetAlpha()), MorphologyOp::apply(rSource.GetRed(), aResult.GetRed()), MorphologyOp::apply(rSource.GetGreen(), aResult.GetGreen()), MorphologyOp::apply(rSource.GetBlue(), aResult.GetBlue())); diff --git a/vcl/source/bitmap/BitmapDisabledImageFilter.cxx b/vcl/source/bitmap/BitmapDisabledImageFilter.cxx index 47e6527953ed..9c4e469191a8 100644 --- a/vcl/source/bitmap/BitmapDisabledImageFilter.cxx +++ b/vcl/source/bitmap/BitmapDisabledImageFilter.cxx @@ -40,7 +40,7 @@ BitmapEx BitmapDisabledImageFilter::execute(BitmapEx const& rBitmapEx) const // Get the luminance from RGB color and remap the value from 0-255 to 160-224 const BitmapColor aColor = pRead->GetPixelFromData(pReadScan, nX); sal_uInt8 nLum(aColor.GetLuminance() / 4 + 160); - BitmapColor aGreyValue(nLum, nLum, nLum, aColor.GetTransparency()); + BitmapColor aGreyValue(nLum, nLum, nLum, 255 - aColor.GetAlpha()); pGrey->SetPixelOnData(pGreyScan, nX, aGreyValue); } } diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx index 18978f779f4a..1f5da07218c4 100644 --- a/vcl/source/bitmap/BitmapEx.cxx +++ b/vcl/source/bitmap/BitmapEx.cxx @@ -574,7 +574,7 @@ bool BitmapEx::Erase( const Color& rFillColor ) // Respect transparency on fill color if( rFillColor.IsTransparent() ) { - const Color aFill( rFillColor.GetTransparency(), rFillColor.GetTransparency(), rFillColor.GetTransparency() ); + const Color aFill( 255 - rFillColor.GetAlpha(), 255 - rFillColor.GetAlpha(), 255 - rFillColor.GetAlpha() ); maMask.Erase( aFill ); } else @@ -684,7 +684,7 @@ sal_uInt8 BitmapEx::GetTransparency(sal_Int32 nX, sal_Int32 nY) const if (nX >= 0 && nX < GetSizePixel().Width() && nY >= 0 && nY < GetSizePixel().Height()) { if (maBitmap.GetBitCount() == 32) - return GetPixelColor(nX, nY).GetTransparency(); + return 255 - GetPixelColor(nX, nY).GetAlpha(); switch(meTransparent) { case TransparentType::NONE: @@ -754,11 +754,11 @@ Color BitmapEx::GetPixelColor(sal_Int32 nX, sal_Int32 nY) const { AlphaMask aAlpha = GetAlpha(); AlphaMask::ScopedReadAccess pAlphaReadAccess(aAlpha); - aColor.SetTransparency(pAlphaReadAccess->GetPixel(nY, nX).GetIndex()); + aColor.SetAlpha(255 - pAlphaReadAccess->GetPixel(nY, nX).GetIndex()); } else if (maBitmap.GetBitCount() != 32) { - aColor.SetTransparency(0); + aColor.SetAlpha(255); } return aColor; } diff --git a/vcl/source/bitmap/BitmapReadAccess.cxx b/vcl/source/bitmap/BitmapReadAccess.cxx index 29df1f28c3b6..0a39835a364c 100644 --- a/vcl/source/bitmap/BitmapReadAccess.cxx +++ b/vcl/source/bitmap/BitmapReadAccess.cxx @@ -427,7 +427,7 @@ void BitmapReadAccess::SetPixelForN32BitTcAbgr(Scanline pScanline, tools::Long n { pScanline = pScanline + nX * 4; - sal_uInt8 alpha = 0xFF - rBitmapColor.GetTransparency(); + sal_uInt8 alpha = rBitmapColor.GetAlpha(); *pScanline++ = alpha; *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetBlue(), alpha); *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetGreen(), alpha); @@ -476,7 +476,7 @@ void BitmapReadAccess::SetPixelForN32BitTcArgb(Scanline pScanline, tools::Long n { pScanline = pScanline + nX * 4; - sal_uInt8 alpha = 0xFF - rBitmapColor.GetTransparency(); + sal_uInt8 alpha = rBitmapColor.GetAlpha(); *pScanline++ = alpha; *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetRed(), alpha); *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetGreen(), alpha); @@ -525,7 +525,7 @@ void BitmapReadAccess::SetPixelForN32BitTcBgra(Scanline pScanline, tools::Long n { pScanline = pScanline + nX * 4; - sal_uInt8 alpha = 0xFF - rBitmapColor.GetTransparency(); + sal_uInt8 alpha = rBitmapColor.GetAlpha(); *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetBlue(), alpha); *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetGreen(), alpha); *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetRed(), alpha); @@ -574,7 +574,7 @@ void BitmapReadAccess::SetPixelForN32BitTcRgba(Scanline pScanline, tools::Long n { pScanline = pScanline + nX * 4; - sal_uInt8 alpha = 0xFF - rBitmapColor.GetTransparency(); + sal_uInt8 alpha = rBitmapColor.GetAlpha(); *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetRed(), alpha); *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetGreen(), alpha); *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetBlue(), alpha); diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index 3c654aaf6980..e4b03cb9de76 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -1101,7 +1101,7 @@ bool convertBitmap32To24Plus8(BitmapEx const & rInput, BitmapEx & rResult) { const BitmapColor aColor = pReadAccess->GetPixelFromData(aReadScan, nX); BitmapColor aResultColor(aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue()); - BitmapColor aResultColorAlpha(aColor.GetTransparency(), aColor.GetTransparency(), aColor.GetTransparency()); + BitmapColor aResultColorAlpha(255 - aColor.GetAlpha(), 255 - aColor.GetAlpha(), 255 - aColor.GetAlpha()); pResultBitmapAccess->SetPixelOnData(aResultScan, nX, aResultColor); pResultAlphaAccess->SetPixelOnData(aResultScanAlpha, nX, aResultColorAlpha); diff --git a/vcl/source/bitmap/BitmapWriteAccess.cxx b/vcl/source/bitmap/BitmapWriteAccess.cxx index c3613223ea94..8d6675ee7ba4 100644 --- a/vcl/source/bitmap/BitmapWriteAccess.cxx +++ b/vcl/source/bitmap/BitmapWriteAccess.cxx @@ -152,7 +152,7 @@ void BitmapWriteAccess::CopyScanline(tools::Long nY, ConstScanline aSrcScanline, void BitmapWriteAccess::SetLineColor(const Color& rColor) { - if (rColor.GetTransparency() == 255) + if (rColor.GetAlpha() == 0) { mpLineColor.reset(); } @@ -173,7 +173,7 @@ void BitmapWriteAccess::SetFillColor() { mpFillColor.reset(); } void BitmapWriteAccess::SetFillColor(const Color& rColor) { - if (rColor.GetTransparency() == 255) + if (rColor.GetAlpha() == 0) { mpFillColor.reset(); } diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 4455b6651d58..a61c67b0c69d 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -100,7 +100,7 @@ TextEngine::TextEngine() vcl::Font aFont; aFont.SetTransparent( false ); Color aFillColor( aFont.GetFillColor() ); - aFillColor.SetTransparency( 0 ); + aFillColor.SetAlpha( 255 ); aFont.SetFillColor( aFillColor ); SetFont( aFont ); } @@ -185,7 +185,7 @@ void TextEngine::SetFont( const vcl::Font& rFont ) // Tell VCL not to use the font color, use text color from OutputDevice maFont.SetColor( COL_TRANSPARENT ); Color aFillColor( maFont.GetFillColor() ); - aFillColor.SetTransparency( 0 ); + aFillColor.SetAlpha( 255 ); maFont.SetFillColor( aFillColor ); maFont.SetAlignment( ALIGN_TOP ); diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx index 998bd68952bb..f7095a0d590c 100644 --- a/vcl/source/edit/textview.cxx +++ b/vcl/source/edit/textview.cxx @@ -267,7 +267,7 @@ void TextView::ImpPaint(vcl::RenderContext& rRenderContext, const Point& rStartP // unfortunately we cannot detect if it has changed vcl::Font aFont = mpImpl->mpTextEngine->GetFont(); Color aColor = rRenderContext.GetBackground().GetColor(); - aColor.SetTransparency(0); + aColor.SetAlpha(255); if (aColor != aFont.GetFillColor()) { if (aFont.IsTransparent()) diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx index 37f5396a6164..f90e992963cc 100644 --- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx +++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx @@ -327,7 +327,8 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics for (gfx::GradientStop const& rStop : pLinearGradient->maGradientStops) { Color aColor(rStop.maColor); - aColor.SetTransparency(rStop.mfOpacity * (1.0f - rRectangle.mnOpacity)); + aColor.SetAlpha(255 + - (rStop.mfOpacity * (1.0f - rRectangle.mnOpacity))); aGradient.maStops.emplace_back(aColor, rStop.mfOffset); } FileDefinitionWidgetDraw::implDrawGradient( diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index d3efe0da4dee..26955027cd99 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -1725,7 +1725,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R Color GDIMetaFile::ImplColAdjustFnc( const Color& rColor, const void* pColParam ) { - return Color( rColor.GetTransparency(), + return Color( 255 - rColor.GetAlpha(), static_cast<const ImplColAdjustParam*>(pColParam)->pMapR[ rColor.GetRed() ], static_cast<const ImplColAdjustParam*>(pColParam)->pMapG[ rColor.GetGreen() ], static_cast<const ImplColAdjustParam*>(pColParam)->pMapB[ rColor.GetBlue() ] ); @@ -1751,7 +1751,7 @@ Color GDIMetaFile::ImplColConvertFnc( const Color& rColor, const void* pColParam if( MtfConversion::N1BitThreshold == static_cast<const ImplColConvertParam*>(pColParam)->eConversion ) cLum = ( cLum < 128 ) ? 0 : 255; - return Color( rColor.GetTransparency(), cLum, cLum, cLum ); + return Color( 255 - rColor.GetAlpha(), cLum, cLum, cLum ); } BitmapEx GDIMetaFile::ImplBmpConvertFnc( const BitmapEx& rBmpEx, const void* pBmpParam ) diff --git a/vcl/source/helper/canvastools.cxx b/vcl/source/helper/canvastools.cxx index 151cb991c050..dc57592944ab 100644 --- a/vcl/source/helper/canvastools.cxx +++ b/vcl/source/helper/canvastools.cxx @@ -568,9 +568,7 @@ namespace vcl::unotools pRet[0] = toDoubleColor(rColor.GetRed()); pRet[1] = toDoubleColor(rColor.GetGreen()); pRet[2] = toDoubleColor(rColor.GetBlue()); - - // VCL's notion of alpha is different from the rest of the world's - pRet[3] = 1.0 - toDoubleColor(rColor.GetTransparency()); + pRet[3] = toDoubleColor(rColor.GetAlpha()); return aRet; } @@ -585,8 +583,7 @@ namespace vcl::unotools aColor.SetRed ( toByteColor(rColor[0]) ); aColor.SetGreen( toByteColor(rColor[1]) ); aColor.SetBlue ( toByteColor(rColor[2]) ); - // VCL's notion of alpha is different from the rest of the world's - aColor.SetTransparency( 255 - toByteColor(rColor[3]) ); + aColor.SetAlpha( toByteColor(rColor[3]) ); return aColor; } @@ -597,7 +594,7 @@ namespace vcl::unotools { uno::Sequence<rendering::ARGBColor> aSeq(1); aSeq[0] = rendering::ARGBColor( - 1.0-toDoubleColor(rColor.GetTransparency()), + toDoubleColor(rColor.GetAlpha()), toDoubleColor(rColor.GetRed()), toDoubleColor(rColor.GetGreen()), toDoubleColor(rColor.GetBlue()) ); diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx index 9760e309dad8..7d07be6fb31c 100644 --- a/vcl/source/outdev/outdevstate.cxx +++ b/vcl/source/outdev/outdevstate.cxx @@ -488,7 +488,7 @@ void OutputDevice::SetBackground( const Wallpaper& rBackground ) else { // Color background. - int transparency = rBackground.GetColor().GetTransparency(); + int transparency = 255 - rBackground.GetColor().GetAlpha(); mpAlphaVDev->SetBackground( Wallpaper( Color( transparency, transparency, transparency ))); } } diff --git a/vcl/source/outdev/pixel.cxx b/vcl/source/outdev/pixel.cxx index 9238c7a394d8..0c021a722452 100644 --- a/vcl/source/outdev/pixel.cxx +++ b/vcl/source/outdev/pixel.cxx @@ -44,7 +44,7 @@ Color OutputDevice::GetPixel(const Point& rPoint) const if (mpAlphaVDev) { Color aAlphaColor = mpAlphaVDev->GetPixel(rPoint); - aColor.SetTransparency(aAlphaColor.GetBlue()); + aColor.SetAlpha(255 - aAlphaColor.GetBlue()); } } } @@ -108,7 +108,7 @@ void OutputDevice::DrawPixel( const Point& rPt, const Color& rColor ) if (mpAlphaVDev) { - Color aAlphaColor(rColor.GetTransparency(), rColor.GetTransparency(), rColor.GetTransparency()); + Color aAlphaColor(255 - rColor.GetAlpha(), 255 - rColor.GetAlpha(), 255 - rColor.GetAlpha()); mpAlphaVDev->DrawPixel(rPt, aAlphaColor); } } diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx index 84e9ec332966..6c47c8a0ac01 100644 --- a/vcl/source/window/menubarwindow.cxx +++ b/vcl/source/window/menubarwindow.cxx @@ -96,7 +96,7 @@ void DecoToolBox::SetImages( tools::Long nMaxHeight, bool bForce ) BitmapEx aBmpExDst( maImage.GetBitmapEx() ); BitmapEx aBmpExSrc( aBmpExDst ); - aEraseColor.SetTransparency( 255 ); + aEraseColor.SetAlpha( 0 ); aBmpExDst.Erase( aEraseColor ); aBmpExDst.Scale( Size( lastSize, lastSize ) ); |