diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-14 17:13:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-15 07:30:47 +0100 |
commit | 14d49662d32fa2fcf2916682dbf1f974a8eecb08 (patch) | |
tree | e96114012ab88665ed7f8701251c56291980ee04 /svx | |
parent | c1ee9b9f746296b916569a1357aa8f1216d40535 (diff) |
move some GDI import code from svx to vcl
part of making ScopedWriteAccess an internal detail of vcl
Change-Id: I916f2ca05c9d7c17b62c91e113df6d8454bb4351
Reviewed-on: https://gerrit.libreoffice.org/51283
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdfmtf.cxx | 83 |
1 files changed, 2 insertions, 81 deletions
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index 457095f6adc0..f3806362aba6 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -71,6 +71,7 @@ #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <svx/svditer.hxx> #include <svx/svdogrp.hxx> +#include <vcl/BitmapTools.hxx> using namespace com::sun::star; @@ -1557,87 +1558,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction const & rAct) } else { - // mix existing and new alpha mask - AlphaMask aOldMask; - - if(aBitmapEx.IsAlpha()) - { - aOldMask = aBitmapEx.GetAlpha(); - } - else if(TransparentType::Bitmap == aBitmapEx.GetTransparentType()) - { - aOldMask = aBitmapEx.GetMask(); - } - else if(TransparentType::Color == aBitmapEx.GetTransparentType()) - { - aOldMask = aBitmapEx.GetBitmap().CreateMask(aBitmapEx.GetTransparentColor()); - } - - AlphaMask::ScopedWriteAccess pOld(aOldMask); - - if(pOld) - { - const double fFactor(1.0 / 255.0); - - if(bFixedTransparence) - { - const double fOpNew(1.0 - fTransparence); - - for(long y(0); y < pOld->Height(); y++) - { - Scanline pScanline = pOld->GetScanline( y ); - for(long x(0); x < pOld->Width(); x++) - { - const double fOpOld(1.0 - (pOld->GetIndexFromData(pScanline, x) * fFactor)); - const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0)); - - pOld->SetPixelOnData(pScanline, x, BitmapColor(aCol)); - } - } - } - else - { - AlphaMask::ScopedReadAccess pNew(aNewMask); - - if(pNew) - { - if(pOld->Width() == pNew->Width() && pOld->Height() == pNew->Height()) - { - for(long y(0); y < pOld->Height(); y++) - { - Scanline pScanline = pOld->GetScanline( y ); - for(long x(0); x < pOld->Width(); x++) - { - const double fOpOld(1.0 - (pOld->GetIndexFromData(pScanline, x) * fFactor)); - const double fOpNew(1.0 - (pNew->GetIndexFromData(pScanline, x) * fFactor)); - const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0)); - - pOld->SetPixelOnData(pScanline, x, BitmapColor(aCol)); - } - } - } - else - { - OSL_ENSURE(false, "Alpha masks have different sizes (!)"); - } - - pNew.reset(); - } - else - { - OSL_ENSURE(false, "Got no access to new alpha mask (!)"); - } - } - - pOld.reset(); - } - else - { - OSL_ENSURE(false, "Got no access to old alpha mask (!)"); - } - - // apply combined bitmap as mask - aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aOldMask); + vcl::bitmap::DrawAlphaBitmapAndAlphaGradient(aBitmapEx, bFixedTransparence, fTransparence, aNewMask); } } |