filter/source/graphicfilter/icgm/actimpr.cxx | 2 include/svx/svdpntv.hxx | 4 - include/toolkit/helper/vclunohelper.hxx | 4 - include/vcl/BitmapTools.hxx | 2 sc/source/ui/unoobj/targuno.cxx | 2 sd/source/ui/unoidl/unopage.cxx | 2 svx/source/inc/UnoGraphicExporter.hxx | 4 - svx/source/svdraw/svdfmtf.cxx | 18 +++--- svx/source/svdraw/svdpntv.cxx | 10 +-- svx/source/unodraw/UnoGraphicExporter.cxx | 4 - svx/source/unodraw/unoshape.cxx | 2 sw/source/uibase/uno/unotxdoc.cxx | 2 toolkit/source/awt/vclxdevice.cxx | 4 - toolkit/source/awt/vclxgraphics.cxx | 6 +- toolkit/source/helper/vclunohelper.cxx | 8 +- vcl/source/bitmap/BitmapTools.cxx | 75 ++++++++++----------------- 16 files changed, 67 insertions(+), 82 deletions(-)
New commits: commit 0a4405f9aa277ec41a3f2152daff264eae098262 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Tue Aug 5 19:29:16 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Tue Aug 5 21:07:56 2025 +0200 BitmapEx->Bitmap in VCLUnoHelper::CreateBitmap now that Bitmap can handle transparency Change-Id: I1de94ef39e00d16b052573ee323886953b574570 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188968 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/filter/source/graphicfilter/icgm/actimpr.cxx b/filter/source/graphicfilter/icgm/actimpr.cxx index 3d51d8e4470a..2b8f4a8ab38a 100644 --- a/filter/source/graphicfilter/icgm/actimpr.cxx +++ b/filter/source/graphicfilter/icgm/actimpr.cxx @@ -600,7 +600,7 @@ void CGMImpressOutAct::DrawBitmap( CGMBitmapDescriptor* pBmpDesc ) ImplSetOrientation( aOrigin, pBmpDesc->mnOrientation ); } - uno::Reference< awt::XBitmap > xBitmap( VCLUnoHelper::CreateBitmap( pBmpDesc->mxBitmap ) ); + uno::Reference< awt::XBitmap > xBitmap( VCLUnoHelper::CreateBitmap( Bitmap(pBmpDesc->mxBitmap) ) ); maXPropSet->setPropertyValue( u"GraphicObjectFillBitmap"_ustr, uno::Any(xBitmap) ); } diff --git a/include/toolkit/helper/vclunohelper.hxx b/include/toolkit/helper/vclunohelper.hxx index 41c6920b57fe..017e751b6506 100644 --- a/include/toolkit/helper/vclunohelper.hxx +++ b/include/toolkit/helper/vclunohelper.hxx @@ -73,8 +73,8 @@ public: static css::uno::Reference< css::awt::XToolkit> CreateToolkit(); // Bitmap - static BitmapEx GetBitmap( const css::uno::Reference< css::awt::XBitmap>& rxBitmap ); - static css::uno::Reference< css::awt::XBitmap> CreateBitmap( const BitmapEx& rBitmap ); + static Bitmap GetBitmap( const css::uno::Reference< css::awt::XBitmap>& rxBitmap ); + static css::uno::Reference< css::awt::XBitmap> CreateBitmap( const Bitmap& rBitmap ); // Window static vcl::Window* GetWindow( const css::uno::Reference< css::awt::XWindow>& rxWindow ); diff --git a/sc/source/ui/unoobj/targuno.cxx b/sc/source/ui/unoobj/targuno.cxx index e7feb8dd3765..0103e3f0513c 100644 --- a/sc/source/ui/unoobj/targuno.cxx +++ b/sc/source/ui/unoobj/targuno.cxx @@ -230,7 +230,7 @@ void ScLinkTargetTypeObj::SetLinkTargetBitmap( uno::Any& rRet, sal_uInt16 nType if (nImgId != ScContentId::ROOT) { BitmapEx aBitmapEx { aContentBmps[static_cast<int>(nImgId) -1 ] }; - rRet <<= VCLUnoHelper::CreateBitmap(aBitmapEx); + rRet <<= VCLUnoHelper::CreateBitmap(Bitmap(aBitmapEx)); } } diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index 4de10123073a..a2fbe686c7da 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -1093,7 +1093,7 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName ) } case WID_PAGE_LDBITMAP: { - Reference< awt::XBitmap > xBitmap(VCLUnoHelper::CreateBitmap(BitmapEx(BMP_PAGE))); + Reference< awt::XBitmap > xBitmap(VCLUnoHelper::CreateBitmap(Bitmap(BitmapEx(BMP_PAGE)))); aAny <<= xBitmap; } break; diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 30c81d9326ad..5336919b8fb4 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -2666,7 +2666,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn } BitmapEx aBmp(sId); - Reference<awt::XBitmap> xBmp(VCLUnoHelper::CreateBitmap(aBmp)); + Reference<awt::XBitmap> xBmp(VCLUnoHelper::CreateBitmap(Bitmap(aBmp))); rValue <<= xBmp; break; diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index f0f4b882a15e..0ea38fb55e1c 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -4681,7 +4681,7 @@ static Any lcl_GetDisplayBitmap(std::u16string_view sLinkSuffix) if (!sImgId.isEmpty()) { - aRet <<= VCLUnoHelper::CreateBitmap(BitmapEx(sImgId)); + aRet <<= VCLUnoHelper::CreateBitmap(Bitmap(BitmapEx(sImgId))); } return aRet; } diff --git a/toolkit/source/awt/vclxdevice.cxx b/toolkit/source/awt/vclxdevice.cxx index 711d014ef554..7648d61ab263 100644 --- a/toolkit/source/awt/vclxdevice.cxx +++ b/toolkit/source/awt/vclxdevice.cxx @@ -133,9 +133,9 @@ css::uno::Reference< css::awt::XDisplayBitmap > VCLXDevice::createDisplayBitmap( { SolarMutexGuard aGuard; - BitmapEx aBmp = VCLUnoHelper::GetBitmap( rxBitmap ); + Bitmap aBmp = VCLUnoHelper::GetBitmap( rxBitmap ); rtl::Reference<VCLXBitmap> pBmp = new VCLXBitmap; - pBmp->SetBitmap( aBmp ); + pBmp->SetBitmap( BitmapEx(aBmp) ); return pBmp; } diff --git a/toolkit/source/awt/vclxgraphics.cxx b/toolkit/source/awt/vclxgraphics.cxx index 2c0987e818d8..d56bc897efd4 100644 --- a/toolkit/source/awt/vclxgraphics.cxx +++ b/toolkit/source/awt/vclxgraphics.cxx @@ -276,10 +276,10 @@ void VCLXGraphics::draw( const uno::Reference< awt::XDisplayBitmap >& rxBitmapHa InitOutputDevice( InitOutDevFlags::NONE); uno::Reference< awt::XBitmap > xBitmap( rxBitmapHandle, uno::UNO_QUERY ); - BitmapEx aBmpEx = VCLUnoHelper::GetBitmap( xBitmap ); + Bitmap aBmp = VCLUnoHelper::GetBitmap( xBitmap ); Point aPos(nDestX - nSourceX, nDestY - nSourceY); - Size aSz = aBmpEx.GetSizePixel(); + Size aSz = aBmp.GetSizePixel(); if(nDestWidth != nSourceWidth) { @@ -296,7 +296,7 @@ void VCLXGraphics::draw( const uno::Reference< awt::XDisplayBitmap >& rxBitmapHa if(nSourceX || nSourceY || aSz.Width() != nSourceWidth || aSz.Height() != nSourceHeight) mpOutputDevice->IntersectClipRegion(vcl::Region(tools::Rectangle(nDestX, nDestY, nDestX + nDestWidth - 1, nDestY + nDestHeight - 1))); - mpOutputDevice->DrawBitmapEx( aPos, aSz, aBmpEx ); + mpOutputDevice->DrawBitmapEx( aPos, aSz, aBmp ); } void VCLXGraphics::drawPixel( sal_Int32 x, sal_Int32 y ) diff --git a/toolkit/source/helper/vclunohelper.cxx b/toolkit/source/helper/vclunohelper.cxx index c83705fbca10..1661db820536 100644 --- a/toolkit/source/helper/vclunohelper.cxx +++ b/toolkit/source/helper/vclunohelper.cxx @@ -59,15 +59,15 @@ uno::Reference< css::awt::XToolkit> VCLUnoHelper::CreateToolkit() return xToolkit; } -BitmapEx VCLUnoHelper::GetBitmap( const css::uno::Reference< css::awt::XBitmap>& rxBitmap ) +Bitmap VCLUnoHelper::GetBitmap( const css::uno::Reference< css::awt::XBitmap>& rxBitmap ) { if (VCLXBitmap* pVCLBitmap = dynamic_cast<VCLXBitmap*>(rxBitmap.get())) - return pVCLBitmap->GetBitmap(); + return Bitmap(pVCLBitmap->GetBitmap()); - return vcl::GetBitmap(rxBitmap); + return Bitmap(vcl::GetBitmap(rxBitmap)); } -css::uno::Reference< css::awt::XBitmap> VCLUnoHelper::CreateBitmap( const BitmapEx& rBitmap ) +css::uno::Reference< css::awt::XBitmap> VCLUnoHelper::CreateBitmap( const Bitmap& rBitmap ) { return Graphic(rBitmap).GetXGraphic().query<css::awt::XBitmap>(); } commit 282c6ade098478d689bb8c12e1d62ea502c2df24 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Tue Aug 5 18:49:40 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Tue Aug 5 21:07:44 2025 +0200 BitmapEx->Bitmap in convertMetafileToBitmap now that Bitmap can handle transparency Change-Id: Iba7fc9164e7dfc0c84a5c13f8336cba0820a3ce7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188967 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/svx/svdpntv.hxx b/include/svx/svdpntv.hxx index 4d641de4dc60..1a8fe08c8df1 100644 --- a/include/svx/svdpntv.hxx +++ b/include/svx/svdpntv.hxx @@ -65,10 +65,10 @@ public: class SdrPaintWindow; /** - * Helper to convert any GDIMetaFile to a good quality BitmapEx, + * Helper to convert any GDIMetaFile to a good quality Bitmap, * using default parameters and graphic::XPrimitive2DRenderer */ -BitmapEx convertMetafileToBitmapEx( +Bitmap convertMetafileToBitmap( const GDIMetaFile& rMtf, const basegfx::B2DRange& rTargetRange, const sal_uInt32 nMaximumQuadraticPixels); diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx index b2cbc868d995..dc4d10091700 100644 --- a/include/vcl/BitmapTools.hxx +++ b/include/vcl/BitmapTools.hxx @@ -68,7 +68,7 @@ VCL_DLLPUBLIC ::Bitmap CanvasTransformBitmap( const ::Bitmap& rBitmap, ::basegfx::B2DRectangle const & rDestRect, ::basegfx::B2DHomMatrix const & rLocalTransform ); -VCL_DLLPUBLIC void DrawAlphaBitmapAndAlphaGradient(BitmapEx & rBitmapEx, bool bFixedTransparence, float fTransparence, const AlphaMask & rNewMask); +VCL_DLLPUBLIC void DrawAlphaBitmapAndAlphaGradient(Bitmap & rBitmap, bool bFixedTransparence, float fTransparence, const AlphaMask & rNewMask); VCL_DLLPUBLIC void DrawAndClipBitmap(const Point& rPos, const Size& rSize, const BitmapEx& rBitmap, BitmapEx & aBmpEx, basegfx::B2DPolyPolygon const & rClipPath); diff --git a/svx/source/inc/UnoGraphicExporter.hxx b/svx/source/inc/UnoGraphicExporter.hxx index 65014c4d7290..27930f04c144 100644 --- a/svx/source/inc/UnoGraphicExporter.hxx +++ b/svx/source/inc/UnoGraphicExporter.hxx @@ -21,14 +21,14 @@ #include <sal/config.h> -#include <vcl/bitmapex.hxx> +#include <vcl/bitmap.hxx> #include <vcl/graph.hxx> class Size; class GDIMetaFile; class SdrObject; -BitmapEx GetBitmapFromMetaFile(const GDIMetaFile& rMtf, const Size* pSize); +Bitmap GetBitmapFromMetaFile(const GDIMetaFile& rMtf, const Size* pSize); Graphic SvxGetGraphicForShape(SdrObject& rShape); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index 3552b8b21525..440548ffc255 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -1513,9 +1513,9 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction const & rAct) const tools::Rectangle aRect(rAct.GetPoint(),rAct.GetSize()); - // convert metafile sub-content to BitmapEx - BitmapEx aBitmapEx( - convertMetafileToBitmapEx( + // convert metafile sub-content to Bitmap + Bitmap aBitmap( + convertMetafileToBitmap( rMtf, vcl::unotools::b2DRectangleFromRectangle(aRect), 125000)); @@ -1569,7 +1569,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction const & rAct) // gradient transparence ScopedVclPtrInstance< VirtualDevice > pVDev; - pVDev->SetOutputSizePixel(aBitmapEx.GetBitmap().GetSizePixel()); + pVDev->SetOutputSizePixel(aBitmap.GetSizePixel()); pVDev->DrawGradient(tools::Rectangle(Point(0, 0), pVDev->GetOutputSizePixel()), rGradient); aNewMask = AlphaMask(pVDev->GetBitmap(Point(0, 0), pVDev->GetOutputSizePixel())); @@ -1582,28 +1582,28 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction const & rAct) if(bHasNewMask || bFixedTransparence) { - if(!aBitmapEx.IsAlpha()) + if(!aBitmap.HasAlpha()) { // no transparence yet, apply new one if(bFixedTransparence) { sal_uInt8 nTransparence(basegfx::fround(fTransparence * 255.0)); - aNewMask = AlphaMask(aBitmapEx.GetBitmap().GetSizePixel(), &nTransparence); + aNewMask = AlphaMask(aBitmap.GetSizePixel(), &nTransparence); } - aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask); + aBitmap = Bitmap(BitmapEx(BitmapEx(aBitmap).GetBitmap(), aNewMask)); } else { - vcl::bitmap::DrawAlphaBitmapAndAlphaGradient(aBitmapEx, bFixedTransparence, fTransparence, aNewMask); + vcl::bitmap::DrawAlphaBitmapAndAlphaGradient(aBitmap, bFixedTransparence, fTransparence, aNewMask); } } // create and add object rtl::Reference<SdrGrafObj> pGraf = new SdrGrafObj( *mpModel, - aBitmapEx, + aBitmap, aRect); // for MetaFloatTransparentAction, do not use SetAttributes(...) diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx index 53373de6acee..e2d26bc8c960 100644 --- a/svx/source/svdraw/svdpntv.cxx +++ b/svx/source/svdraw/svdpntv.cxx @@ -104,12 +104,12 @@ SvxViewChangedHint::SvxViewChangedHint() : SfxHint(SfxHintId::SvxViewChanged) } -BitmapEx convertMetafileToBitmapEx( +Bitmap convertMetafileToBitmap( const GDIMetaFile& rMtf, const basegfx::B2DRange& rTargetRange, const sal_uInt32 nMaximumQuadraticPixels) { - BitmapEx aBitmapEx; + Bitmap aBitmap; if(rMtf.GetActionSize()) { @@ -119,13 +119,13 @@ BitmapEx convertMetafileToBitmapEx( rTargetRange.getRange(), rTargetRange.getMinimum()), rMtf)); - aBitmapEx = drawinglayer::convertPrimitive2DContainerToBitmapEx( + aBitmap = Bitmap(drawinglayer::convertPrimitive2DContainerToBitmapEx( drawinglayer::primitive2d::Primitive2DContainer { aMtf }, rTargetRange, - nMaximumQuadraticPixels); + nMaximumQuadraticPixels)); } - return aBitmapEx; + return aBitmap; } SdrPaintView::SdrPaintView(SdrModel& rSdrModel, OutputDevice* pOut) diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index 7fc53a73d329..aff08a85e2c6 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -1271,7 +1271,7 @@ Sequence< OUString > SAL_CALL GraphicExporter::getSupportedMimeTypeNames( ) /** creates a bitmap that is optionally transparent from a metafile */ -BitmapEx GetBitmapFromMetaFile(const GDIMetaFile& rMtf, const Size* pSize) +Bitmap GetBitmapFromMetaFile(const GDIMetaFile& rMtf, const Size* pSize) { // use new primitive conversion tooling basegfx::B2DRange aRange(basegfx::B2DPoint(0.0, 0.0)); @@ -1302,7 +1302,7 @@ BitmapEx GetBitmapFromMetaFile(const GDIMetaFile& rMtf, const Size* pSize) nMaximumQuadraticPixels = 2048 * 2048; } - return convertMetafileToBitmapEx(rMtf, aRange, nMaximumQuadraticPixels); + return convertMetafileToBitmap(rMtf, aRange, nMaximumQuadraticPixels); } Graphic SvxGetGraphicForShape( SdrObject& rShape ) diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index a48270bab507..7e6f864f0e6d 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -520,67 +520,52 @@ Bitmap CanvasTransformBitmap( const Bitmap& rSrcBitmap, return aDstBitmap; } -void DrawAlphaBitmapAndAlphaGradient(BitmapEx & rBitmapEx, bool bFixedTransparence, float fTransparence, const AlphaMask & rNewMask) +// mix existing and new alpha mask +void DrawAlphaBitmapAndAlphaGradient(Bitmap & rBitmap, bool bFixedTransparence, float fTransparence, const AlphaMask & rNewMask) { - // mix existing and new alpha mask - AlphaMask aOldMask; + const double fFactor(1.0 / 255.0); + BitmapScopedWriteAccess pOld(rBitmap); + assert(pOld && "Got no access to old alpha mask (!)"); - if(rBitmapEx.IsAlpha()) + if(bFixedTransparence) { - aOldMask = rBitmapEx.GetAlphaMask(); - } - - { - - BitmapScopedWriteAccess pOld(aOldMask); - - assert(pOld && "Got no access to old alpha mask (!)"); + const double fOpNew(1.0 - fTransparence); - const double fFactor(1.0 / 255.0); - - if(bFixedTransparence) + for(tools::Long y(0),nHeight(pOld->Height()); y < nHeight; y++) { - const double fOpNew(1.0 - fTransparence); - - for(tools::Long y(0),nHeight(pOld->Height()); y < nHeight; y++) + Scanline pScanline = pOld->GetScanline( y ); + for(tools::Long x(0),nWidth(pOld->Width()); x < nWidth; x++) { - Scanline pScanline = pOld->GetScanline( y ); - for(tools::Long x(0),nWidth(pOld->Width()); x < nWidth; x++) - { - const double fOpOld(pOld->GetIndexFromData(pScanline, x) * fFactor); - const sal_uInt8 aCol(basegfx::fround((fOpOld * fOpNew) * 255.0)); + BitmapColor aCol = pOld->GetPixelFromData(pScanline, x); + const double fOpOld(aCol.GetAlpha() * fFactor); + aCol.SetAlpha(basegfx::fround((fOpOld * fOpNew) * 255.0)); - pOld->SetPixelOnData(pScanline, x, BitmapColor(aCol)); - } + pOld->SetPixelOnData(pScanline, x, aCol); } } - else - { - BitmapScopedReadAccess pNew(rNewMask); - - assert(pNew && "Got no access to new alpha mask (!)"); + } + else + { + BitmapScopedReadAccess pNew(rNewMask); + assert(pNew && "Got no access to new alpha mask (!)"); - assert(pOld->Width() == pNew->Width() && pOld->Height() == pNew->Height() && - "Alpha masks have different sizes (!)"); + assert(pOld->Width() == pNew->Width() && pOld->Height() == pNew->Height() && + "Alpha masks have different sizes (!)"); - for(tools::Long y(0),nHeight(pOld->Height()); y < nHeight; y++) + for(tools::Long y(0),nHeight(pOld->Height()); y < nHeight; y++) + { + Scanline pScanline = pOld->GetScanline( y ); + for(tools::Long x(0),nWidth(pOld->Width()); x < nWidth; x++) { - Scanline pScanline = pOld->GetScanline( y ); - for(tools::Long x(0),nWidth(pOld->Width()); x < nWidth; x++) - { - const double fOpOld(pOld->GetIndexFromData(pScanline, x) * fFactor); - const double fOpNew(pNew->GetIndexFromData(pScanline, x) * fFactor); - const sal_uInt8 aCol(basegfx::fround((fOpOld * fOpNew) * 255.0)); + BitmapColor aCol = pOld->GetPixelFromData(pScanline, x); + const double fOpOld(aCol.GetAlpha() * fFactor); + const double fOpNew(pNew->GetIndexFromData(pScanline, x) * fFactor); + aCol.SetAlpha(basegfx::fround((fOpOld * fOpNew) * 255.0)); - pOld->SetPixelOnData(pScanline, x, BitmapColor(aCol)); - } + pOld->SetPixelOnData(pScanline, x, aCol); } } - } - - // apply combined bitmap as mask - rBitmapEx = BitmapEx(rBitmapEx.GetBitmap(), aOldMask); }