[Libreoffice-commits] core.git: svx/inc svx/source vcl/inc vcl/source
svx/inc/tbxcolorupdate.hxx | 10 ++ svx/source/tbxctrls/tbxcolorupdate.cxx | 27 ++- vcl/inc/image.h|5 - vcl/source/image/Image.cxx |2 ++ vcl/source/image/ImplImage.cxx | 24 ++-- 5 files changed, 60 insertions(+), 8 deletions(-) New commits: commit c3da84a10260b3260ee42df900e2ff01119e4f7c Author: Caolán McNamara AuthorDate: Fri Nov 11 15:52:51 2022 + Commit: Caolán McNamara CommitDate: Fri Nov 11 20:36:14 2022 +0100 Resolves: tdf#151898 get hidpi font/highlight color icons Most of this wouldn't be necessary if we could solve the split alpha problem. In the meantime, let Image take a MetaFile as an arg, record what we want to do in the metafile, and play it back when we need to generate the bitmap for to render the image. That way we don't have alpha to worry about during the recording, and we only have one alpha in the final rendering, as opposed to having two alphas in a source and in destination VirtualDevice, which is problematic in most backends. Change-Id: I5b0d7c498473271f4ab2743f75614b1b93a0e9c9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142593 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/svx/inc/tbxcolorupdate.hxx b/svx/inc/tbxcolorupdate.hxx index 0ad6f502243a..d496a6921fab 100644 --- a/svx/inc/tbxcolorupdate.hxx +++ b/svx/inc/tbxcolorupdate.hxx @@ -83,6 +83,8 @@ namespace svx virtual OUString GetQuickHelpText() const = 0; virtual void SetImage(VirtualDevice* pVirDev) = 0; virtual VclPtr CreateVirtualDevice() const = 0; +// true -> use Device to Record to Metafile, false -> Render to Device +virtual bool RecordVirtualDevice() const = 0; virtual vcl::ImageType GetImageSize() const = 0; virtual Size GetItemSize(const Size& rImageSize) const = 0; }; @@ -103,6 +105,10 @@ namespace svx virtual OUString GetQuickHelpText() const override; virtual void SetImage(VirtualDevice* pVirDev) override; virtual VclPtr CreateVirtualDevice() const override; +virtual bool RecordVirtualDevice() const override +{ +return true; +} virtual vcl::ImageType GetImageSize() const override; virtual Size GetItemSize(const Size& rImageSize) const override; }; @@ -121,6 +127,10 @@ namespace svx virtual OUString GetQuickHelpText() const override; virtual void SetImage(VirtualDevice* pVirDev) override; virtual VclPtr CreateVirtualDevice() const override; +virtual bool RecordVirtualDevice() const override +{ +return false; +} virtual vcl::ImageType GetImageSize() const override; virtual Size GetItemSize(const Size& rImageSize) const override; }; diff --git a/svx/source/tbxctrls/tbxcolorupdate.cxx b/svx/source/tbxctrls/tbxcolorupdate.cxx index 37c8db06cf50..4e438c3ede9c 100644 --- a/svx/source/tbxctrls/tbxcolorupdate.cxx +++ b/svx/source/tbxctrls/tbxcolorupdate.cxx @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -102,15 +103,21 @@ namespace svx void VclToolboxButtonColorUpdater::SetImage(VirtualDevice* pVirDev) { -mpTbx->SetItemImage(mnBtnId, Image(pVirDev->GetBitmapEx(Point(0,0), maBmpSize))); +GDIMetaFile* pMtf = pVirDev->GetConnectMetaFile(); + +assert(pMtf && "should have been set in ToolboxButtonColorUpdaterBase::Update"); + +pMtf->Stop(); +pMtf->WindStart(); + +Graphic aGraphic(*pMtf); + +mpTbx->SetItemImage(mnBtnId, Image(aGraphic.GetXGraphic())); } VclPtr VclToolboxButtonColorUpdater::CreateVirtualDevice() const { -auto xRet = VclPtr::Create(*mpTbx->GetOutDev(), -DeviceFormat::DEFAULT, DeviceFormat::DEFAULT); -xRet->SetBackground(mpTbx->GetControlBackground()); -return xRet; +return VclPtr::Create(*mpTbx->GetOutDev()); } vcl::ImageType VclToolboxButtonColorUpdater::GetImageSize() const @@ -172,6 +179,16 @@ namespace svx pVirDev->SetOutputSizePixel(aItemSize); maBmpSize = aItemSize; +std::unique_ptr xMetaFile; +if (RecordVirtualDevice()) +{ +xMetaFile.reset(new GDIMetaFile); +xMetaFile->SetPrefSize(pVirDev->GetOutputSize()); +xMetaFile->SetPrefMapMode(pVirDev->GetMapMode()); +xMetaFile->Record(pVirDev.get()); +pVirDev->EnableOutput(false); +} + if (maBmpSize.Width() == maBmpSize.Height()) // tdf#84985 align color bar with icon bottom edge; integer arithmetic e.g. 26 - 26/4 <> 26 * 3/4 maUpdRect = tools::Rectangle(Point( 0, maBmpSize.Height() - maBmpSize.Height() / 4), Size(maBmpSize.Width(), maBmpSize.Height() / 4)); diff --git a/vcl/i
[Libreoffice-commits] core.git: svx/inc svx/source vcl/inc vcl/source
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 33b4c9938ddcfb55088531cce3f2493c1459 Author: Armin Le Grand Date: Mon May 14 14:21:26 2012 + 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 = 50); + 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 #include #include -#include -#include +#include +#include +#include @@ -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)); - -