svx/inc/svx/svdpntv.hxx | 9 +++ svx/source/svdraw/svdfmtf.cxx | 109 +++++++++++++++++++++++++++--------------- svx/source/svdraw/svdpntv.cxx | 30 ++++++++++- svx/source/svdraw/svdxcgv.cxx | 36 +++++-------- vcl/inc/vcl/svgdata.hxx | 3 - vcl/source/gdi/impgraph.cxx | 4 - vcl/source/gdi/svgdata.cxx | 5 + 7 files changed, 126 insertions(+), 70 deletions(-)
New commits: commit 33b4c9938ddcf5555b55088531cce3f2493c1459 Author: Armin Le Grand <a...@apache.org> Date: Mon May 14 14:21:26 2012 +0000 Resolves: #i119125# various actions implemented, clipping added. Esp hard was ImpSdrGDIMetaFileImport, but working now. Needed to hand-craft alpha addition for alpha in Metafile content and gradient of action. Also added better BitmapEx creation for convert to bitmap for draw objects. Conflicts: svx/source/svdraw/svdxcgv.cxx vcl/source/gdi/impgraph.cxx Change-Id: Ic6ac9fb3132dd122e16a5cd8f9c5ddd155ec9882 diff --git a/svx/inc/svx/svdpntv.hxx b/svx/inc/svx/svdpntv.hxx index eca5710f..2e9bc25 100644 --- a/svx/inc/svx/svdpntv.hxx +++ b/svx/inc/svx/svdpntv.hxx @@ -113,6 +113,15 @@ private: class SdrPaintWindow; typedef ::std::vector< SdrPaintWindow* > SdrPaintWindowVector; +////////////////////////////////////////////////////////////////////////////// +// helper to convert any GDIMetaFile to a good quality BitmapEx, +// using default parameters and graphic::XPrimitive2DRenderer + +BitmapEx SVX_DLLPUBLIC convertMetafileToBitmapEx( + const GDIMetaFile& rMtf, + const basegfx::B2DRange& rTargetRange, + const sal_uInt32 nMaximumQuadraticPixels = 500000); + //////////////////////////////////////////////////////////////////////////////////////////////////// class SVX_DLLPUBLIC SdrPaintView : public SfxListener, public SfxRepeatTarget, public SfxBroadcaster, public ::utl::ConfigurationListener diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index 4d9af43..583e54c 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -65,8 +65,9 @@ #include <svx/xbtmpit.hxx> #include <svx/xfltrit.hxx> #include <vcl/bmpacc.hxx> -#include <vcl/svgdata.hxx> -#include <drawinglayer/primitive2d/metafileprimitive2d.hxx> +#include <svx/xflbmtit.hxx> +#include <svx/xflbstit.hxx> +#include <svx/svdpntv.hxx> //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -513,6 +514,8 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale) pObj->SetMergedItem(XFillStyleItem(XFILL_BITMAP)); pObj->SetMergedItem(XFillBitmapItem(String(), Graphic(aClippedBitmap))); + pObj->SetMergedItem(XFillBmpTileItem(false)); + pObj->SetMergedItem(XFillBmpStretchItem(true)); } } } @@ -1399,21 +1402,16 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct) if(rMtf.GetActionSize()) { - Rectangle aRect(rAct.GetPoint(),rAct.GetSize()); - aRect.Right()++; aRect.Bottom()++; - - // get metafile content as bitmap - const basegfx::B2DRange aTargetRange( - aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom()); - const drawinglayer::primitive2d::Primitive2DReference aMtf( - new drawinglayer::primitive2d::MetafilePrimitive2D( - basegfx::tools::createScaleTranslateB2DHomMatrix( - aTargetRange.getRange(), - aTargetRange.getMinimum()), - rMtf)); - BitmapEx aBitmapEx(convertPrimitive2DSequenceToBitmapEx( - drawinglayer::primitive2d::Primitive2DSequence(&aMtf, 1), - aTargetRange)); + const Rectangle aRect(rAct.GetPoint(),rAct.GetSize()); + + // convert metafile sub-content to BitmapEx + BitmapEx aBitmapEx( + convertMetafileToBitmapEx( + rMtf, + basegfx::B2DRange( + aRect.Left(), aRect.Top(), + aRect.Right(), aRect.Bottom()), + 125000)); // handle colors const Gradient& rGradient = rAct.GetGradient(); @@ -1435,12 +1433,14 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct) bool bCreateObject(true); bool bHasNewMask(false); AlphaMask aNewMask; + double fTransparence(0.0); + bool bFixedTransparence(false); if(bEqualColors || bNoSteps) { // single transparence const basegfx::BColor aMedium(basegfx::average(aStart, aEnd)); - const double fTransparence(aMedium.luminance()); + fTransparence = aMedium.luminance(); if(basegfx::fTools::lessOrEqual(fTransparence, 0.0)) { @@ -1453,11 +1453,8 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct) } else { - // 0.0 < transparence < 1.0, apply - sal_uInt8 aAlpha(basegfx::fround(fTransparence * 255.0)); - - aNewMask = AlphaMask(aBitmapEx.GetBitmap().GetSizePixel(), &aAlpha); - bHasNewMask = true; + // 0.0 < transparence < 1.0, apply fixed transparence + bFixedTransparence = true; } } else @@ -1474,11 +1471,18 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct) if(bCreateObject) { - if(bHasNewMask) + if(bHasNewMask || bFixedTransparence) { if(!aBitmapEx.IsAlpha() && !aBitmapEx.IsTransparent()) { // no transparence yet, apply new one + if(bFixedTransparence) + { + sal_uInt8 aAlpha(basegfx::fround(fTransparence * 255.0)); + + aNewMask = AlphaMask(aBitmapEx.GetBitmap().GetSizePixel(), &aAlpha); + } + aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask); } else @@ -1499,40 +1503,69 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct) aOldMask = aBitmapEx.GetBitmap().CreateMask(aBitmapEx.GetTransparentColor()); } - BitmapReadAccess* pOld = aOldMask.AcquireReadAccess(); - BitmapWriteAccess* pNew = aNewMask.AcquireWriteAccess(); + BitmapWriteAccess* pOld = aOldMask.AcquireWriteAccess(); - if(pOld && pNew) + if(pOld) { - if(pOld->Width() == pNew->Width() && pOld->Height() == pNew->Height()) + const double fFactor(1.0 / 255.0); + + if(bFixedTransparence) { - for(sal_uInt32 y(0); y < pNew->Height(); y++) + const double fOpNew(1.0 - fTransparence); + + for(sal_uInt32 y(0); y < pOld->Height(); y++) { - for(sal_uInt32 x(0); x < pNew->Width(); x++) + for(sal_uInt32 x(0); x < pOld->Width(); x++) { - const BitmapColor aColOld(pOld->GetPixel(y, x)); - const BitmapColor aColNew(pNew->GetPixel(y, x)); - const sal_uInt16 aCombine(sal_uInt16(aColOld.GetIndex()) + sal_uInt16(aColNew.GetIndex())); + const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor)); + const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0)); - pNew->SetPixel(y, x, BitmapColor(aCombine > 255 ? 255 : sal_uInt8(aCombine))); + pOld->SetPixel(y, x, BitmapColor(aCol)); } } } else { - OSL_ENSURE(false, "Alpha masks have different sizes (!)"); + BitmapReadAccess* pNew = aNewMask.AcquireReadAccess(); + + if(pNew) + { + if(pOld->Width() == pNew->Width() && pOld->Height() == pNew->Height()) + { + for(sal_uInt32 y(0); y < pOld->Height(); y++) + { + for(sal_uInt32 x(0); x < pOld->Width(); x++) + { + const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor)); + const double fOpNew(1.0 - (pNew->GetPixel(y, x).GetIndex() * fFactor)); + const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0)); + + pOld->SetPixel(y, x, BitmapColor(aCol)); + } + } + } + else + { + OSL_ENSURE(false, "Alpha masks have different sizes (!)"); + } + + aNewMask.ReleaseAccess(pNew); + } + else + { + OSL_ENSURE(false, "Got no access to new alpha mask (!)"); + } } aOldMask.ReleaseAccess(pOld); - aNewMask.ReleaseAccess(pNew); } else { - OSL_ENSURE(false, "Got no access to alpha bitmaps (!)"); + OSL_ENSURE(false, "Got no access to old alpha mask (!)"); } // apply combined bitmap as mask - aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask); + aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aOldMask); } } diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx index 3f53923..6e9993a 100644 --- a/svx/source/svdraw/svdpntv.cxx +++ b/svx/source/svdraw/svdpntv.cxx @@ -54,11 +54,11 @@ #include <vcl/svapp.hxx> #include <com/sun/star/awt/PosSize.hpp> #include <com/sun/star/awt/XControl.hpp> - -// #i38135# #include <svx/sdr/contact/objectcontact.hxx> #include <svx/sdr/animation/objectanimator.hxx> #include <svx/sdr/contact/viewcontact.hxx> +#include <drawinglayer/primitive2d/metafileprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> using namespace ::rtl; using namespace ::com::sun::star; @@ -136,6 +136,32 @@ SvxViewHint::HintType SvxViewHint::GetHintType (void) const //////////////////////////////////////////////////////////////////////////////////////////////////// +BitmapEx convertMetafileToBitmapEx( + const GDIMetaFile& rMtf, + const basegfx::B2DRange& rTargetRange, + const sal_uInt32 nMaximumQuadraticPixels) +{ + BitmapEx aBitmapEx; + + if(rMtf.GetActionSize()) + { + const drawinglayer::primitive2d::Primitive2DReference aMtf( + new drawinglayer::primitive2d::MetafilePrimitive2D( + basegfx::tools::createScaleTranslateB2DHomMatrix( + rTargetRange.getRange(), + rTargetRange.getMinimum()), + rMtf)); + aBitmapEx = convertPrimitive2DSequenceToBitmapEx( + drawinglayer::primitive2d::Primitive2DSequence(&aMtf, 1), + rTargetRange, + nMaximumQuadraticPixels); + } + + return aBitmapEx; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + TYPEINIT2(SdrPaintView,SfxListener,SfxRepeatTarget); DBG_NAME(SdrPaintView); diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx index 6256e23..a85b378 100644 --- a/svx/source/svdraw/svdxcgv.cxx +++ b/svx/source/svdraw/svdxcgv.cxx @@ -19,11 +19,12 @@ #include <vector> #include <editeng/editeng.hxx> -#include "svx/xexch.hxx" +#include <rtl/strbuf.hxx> +#include <svx/xexch.hxx> #include <svx/xflclit.hxx> #include <svx/svdxcgv.hxx> #include <svx/svdoutl.hxx> -#include "svx/svditext.hxx" +#include <svx/svditext.hxx> #include <svx/svdetc.hxx> #include <svx/svdundo.hxx> #include <svx/svdograf.hxx> @@ -42,16 +43,11 @@ #include <svl/itempool.hxx> #include <tools/bigint.hxx> #include <sot/formats.hxx> - -// #i13033# #include <clonelist.hxx> #include <vcl/virdev.hxx> - #include <svl/style.hxx> - -// #i72535# -#include "fmobj.hxx" -#include <rtl/strbuf.hxx> +#include <fmobj.hxx> +#include <vcl/svgdata.hxx> //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -442,8 +438,6 @@ void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Po } } -//////////////////////////////////////////////////////////////////////////////////////////////////// - BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked) const { BitmapEx aBmp; @@ -475,18 +469,14 @@ BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked) const if( !aBmp ) { - const Graphic aGraphic(GetMarkedObjMetaFile(bNoVDevIfOneBmpMarked)); - - // #i102089# support user's settings of AA and LineSnap when the MetaFile gets - // raster-converted to a bitmap - const SvtOptionsDrawinglayer aDrawinglayerOpt; - const GraphicConversionParameters aParameters( - Size(), - false, - aDrawinglayerOpt.IsAntiAliasing(), - aDrawinglayerOpt.IsSnapHorVerLinesToDiscrete()); - - aBmp = aGraphic.GetBitmapEx(aParameters); + const GDIMetaFile aGDIMetaFile(GetMarkedObjMetaFile(bNoVDevIfOneBmpMarked)); + const Rectangle aBound(GetMarkedObjBoundRect()); + + aBmp = convertMetafileToBitmapEx( + aGDIMetaFile, + basegfx::B2DRange( + aBound.Left(), aBound.Top(), + aBound.Right(), aBound.Bottom())); } } diff --git a/vcl/inc/vcl/svgdata.hxx b/vcl/inc/vcl/svgdata.hxx index eaba004..8de8d3a 100644 --- a/vcl/inc/vcl/svgdata.hxx +++ b/vcl/inc/vcl/svgdata.hxx @@ -40,7 +40,8 @@ typedef ::com::sun::star::uno::Sequence< Primitive2DReference > Primitive2DSeque BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx( const Primitive2DSequence& rSequence, - const basegfx::B2DRange& rTargetRange); + const basegfx::B2DRange& rTargetRange, + const sal_uInt32 nMaximumQuadraticPixels = 500000); ////////////////////////////////////////////////////////////////////////////// diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 2421bcb..fc161a2 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -25,9 +25,7 @@ #include <tools/debug.hxx> #include <tools/stream.hxx> #include <tools/helpers.hxx> - #include <ucbhelper/content.hxx> - #include <unotools/ucbstreamhelper.hxx> #include <unotools/tempfile.hxx> #include <vcl/outdev.hxx> @@ -36,9 +34,7 @@ #include <vcl/cvtgrf.hxx> #include <vcl/graph.hxx> #include <vcl/metaact.hxx> - #include <impgraph.hxx> - #include <com/sun/star/ucb/CommandAbortedException.hpp> // ----------- diff --git a/vcl/source/gdi/svgdata.cxx b/vcl/source/gdi/svgdata.cxx index 9772e92..1db7c37 100644 --- a/vcl/source/gdi/svgdata.cxx +++ b/vcl/source/gdi/svgdata.cxx @@ -37,7 +37,8 @@ using namespace ::com::sun::star; BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx( const Primitive2DSequence& rSequence, - const basegfx::B2DRange& rTargetRange) + const basegfx::B2DRange& rTargetRange, + const sal_uInt32 nMaximumQuadraticPixels) { BitmapEx aRetval; @@ -72,7 +73,7 @@ BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx( aDPI.getWidth(), aDPI.getHeight(), aRealRect, - 500000)); + nMaximumQuadraticPixels)); if(xBitmap.is()) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits