vcl/source/gdi/gdimetafiletools.cxx | 122 +----------------------------------- vcl/source/gdi/impgraph.cxx | 6 - 2 files changed, 7 insertions(+), 121 deletions(-)
New commits: commit 7bd6f3cfb05b687d55444d629702b456b718b16e Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Sep 4 14:54:02 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Sep 4 18:00:08 2025 +0200 BitmapEx->Bitmap in metafiletools now that Bitmap supports transparency Change-Id: Iba3ba6d3bf82eddbdebf1adf831089c2a756547d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190589 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/vcl/source/gdi/gdimetafiletools.cxx b/vcl/source/gdi/gdimetafiletools.cxx index 803c1d4eda0f..49a9304057c2 100644 --- a/vcl/source/gdi/gdimetafiletools.cxx +++ b/vcl/source/gdi/gdimetafiletools.cxx @@ -117,120 +117,6 @@ namespace return true; } - bool handleBitmapContent( - const basegfx::B2DPolyPolygon& rClip, - const Point& rPoint, - const Size& rSize, - const BitmapEx& rBitmapEx, - GDIMetaFile& rTarget) - { - if(!rSize.Width() || !rSize.Height() || rBitmapEx.IsEmpty()) - { - // bitmap or size is empty - return true; - } - - const basegfx::B2DRange aLogicBitmapRange( - rPoint.X(), rPoint.Y(), - rPoint.X() + rSize.Width(), rPoint.Y() + rSize.Height()); - const basegfx::B2DPolyPolygon aClipOfBitmap( - basegfx::utils::clipPolyPolygonOnRange( - rClip, - aLogicBitmapRange, - true, - false)); // stroke - - if(!aClipOfBitmap.count()) - { - // outside clip region - return true; - } - - // inside or overlapping. Use area to find out if it is completely - // covering (inside) or overlapping - const double fClipArea(basegfx::utils::getArea(aClipOfBitmap)); - const double fBitmapArea( - aLogicBitmapRange.getWidth() * aLogicBitmapRange.getWidth() + - aLogicBitmapRange.getHeight() * aLogicBitmapRange.getHeight()); - const double fFactor(fClipArea / fBitmapArea); - - if(basegfx::fTools::more(fFactor, 1.0 - 0.001)) - { - // completely covering (with 0.1% tolerance) - return false; - } - - // needs clipping (with 0.1% tolerance). Prepare VirtualDevice - // in pixel mode for alpha channel painting (black is transparent, - // white to paint 100% opacity) - const Size aSizePixel(rBitmapEx.GetSizePixel()); - ScopedVclPtrInstance< VirtualDevice > aVDev; - - aVDev->SetOutputSizePixel(aSizePixel); - aVDev->EnableMapMode(false); - aVDev->SetFillColor( COL_WHITE); - aVDev->SetLineColor(); - - if(rBitmapEx.IsAlpha()) - { - // use given alpha channel - aVDev->DrawBitmap(Point(0, 0), rBitmapEx.GetAlphaMask().GetBitmap()); - } - else - { - // reset alpha channel - aVDev->SetBackground(Wallpaper(COL_BLACK)); - aVDev->Erase(); - } - - // transform polygon from clipping to pixel coordinates - basegfx::B2DPolyPolygon aPixelPoly(aClipOfBitmap); - basegfx::B2DHomMatrix aTransform; - - aTransform.translate(-aLogicBitmapRange.getMinX(), -aLogicBitmapRange.getMinY()); - aTransform.scale( - static_cast< double >(aSizePixel.Width()) / aLogicBitmapRange.getWidth(), - static_cast< double >(aSizePixel.Height()) / aLogicBitmapRange.getHeight()); - aPixelPoly.transform(aTransform); - - // to fill the non-covered parts, use the Xor fill rule of - // tools::PolyPolygon painting. Start with an all-covering polygon and - // add the clip polygon one - basegfx::B2DPolyPolygon aInvertPixelPoly; - - aInvertPixelPoly.append( - basegfx::utils::createPolygonFromRect( - basegfx::B2DRange( - 0.0, 0.0, - aSizePixel.Width(), aSizePixel.Height()))); - aInvertPixelPoly.append(aPixelPoly); - - // paint as alpha - aVDev->DrawPolyPolygon(aInvertPixelPoly); - - // get created alpha mask and set defaults - AlphaMask aAlpha( - aVDev->GetBitmap( - Point(0, 0), - aSizePixel)); - - aAlpha.SetPrefSize(rBitmapEx.GetPrefSize()); - aAlpha.SetPrefMapMode(rBitmapEx.GetPrefMapMode()); - - // add new action replacing the old one - rTarget.AddAction( - new MetaBmpExScaleAction( - Point( - basegfx::fround<tools::Long>(aLogicBitmapRange.getMinX()), - basegfx::fround<tools::Long>(aLogicBitmapRange.getMinY())), - Size( - basegfx::fround<tools::Long>(aLogicBitmapRange.getWidth()), - basegfx::fround<tools::Long>(aLogicBitmapRange.getHeight())), - Bitmap(rBitmapEx.GetBitmap(), aAlpha))); - - return true; - } - bool handleBitmapContent( const basegfx::B2DPolyPolygon& rClip, const Point& rPoint, @@ -813,7 +699,7 @@ void clipMetafileContentAgainstOwnRegions(GDIMetaFile& rSource) break; } - // bitmap actions, create BitmapEx with alpha channel derived + // bitmap actions, create Bitmap with alpha channel derived // from clipping case MetaActionType::BMPEX : @@ -865,7 +751,7 @@ void clipMetafileContentAgainstOwnRegions(GDIMetaFile& rSource) aClips.back(), pA->GetPoint(), aLogicalSize, - BitmapEx(rBitmap), + rBitmap, aTarget); break; } @@ -891,7 +777,7 @@ void clipMetafileContentAgainstOwnRegions(GDIMetaFile& rSource) aClips.back(), pA->GetPoint(), pA->GetSize(), - BitmapEx(pA->GetBitmap()), + pA->GetBitmap(), aTarget); break; } @@ -957,7 +843,7 @@ void clipMetafileContentAgainstOwnRegions(GDIMetaFile& rSource) aClips.back(), pA->GetDestPoint(), pA->GetDestSize(), - BitmapEx(aCroppedBitmap), + aCroppedBitmap, aTarget); } } commit d5482f71d04be28f139bdb363615d0ad9836faae Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Sep 4 14:50:47 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Sep 4 17:59:58 2025 +0200 BitmapEx->Bitmap in ImpGraphic now that Bitmap supports transparency Change-Id: I413d9e5520153828e8ef3500600bd98e315a7950 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190588 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 1f8aa8dc788c..c52bd6c717eb 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -1602,11 +1602,11 @@ bool ImpGraphic::swapInGraphic(SvStream& rStream) { case GraphicContentType::Bitmap: { - BitmapEx aBitmapEx; - ReadDIBBitmapEx(aBitmapEx, rStream); + Bitmap aBitmap; + ReadDIBBitmapEx(aBitmap, rStream); if (!rStream.GetError()) { - mpBitmapContainer = std::make_shared<BitmapContainer>(Bitmap(aBitmapEx)); + mpBitmapContainer = std::make_shared<BitmapContainer>(aBitmap); bReturn = true; } }