cppcanvas/source/mtfrenderer/implrenderer.cxx | 2 drawinglayer/source/tools/wmfemfhelper.cxx | 4 filter/source/svg/svgwriter.cxx | 6 - include/vcl/gdimtf.hxx | 11 +- include/vcl/metaact.hxx | 10 +- sd/source/ui/view/sdview3.cxx | 2 sfx2/source/doc/SfxRedactionHelper.cxx | 2 slideshow/source/engine/shapes/gdimtftools.cxx | 10 +- svx/source/dialog/_bmpmask.cxx | 4 svx/source/svdraw/svdfmtf.cxx | 4 vcl/qa/cppunit/svm/svmtest.cxx | 20 ++-- vcl/source/filter/eps/eps.cxx | 6 - vcl/source/filter/svm/SvmReader.cxx | 6 - vcl/source/filter/svm/SvmWriter.cxx | 6 - vcl/source/filter/wmf/emfwr.cxx | 4 vcl/source/filter/wmf/wmfwr.cxx | 4 vcl/source/gdi/gdimetafiletools.cxx | 124 +++++++++++++++++++++++-- vcl/source/gdi/gdimtf.cxx | 38 +++---- vcl/source/gdi/metaact.cxx | 6 - vcl/source/gdi/mtfxmldump.cxx | 4 vcl/source/gdi/pdfwriter_impl2.cxx | 8 - vcl/source/outdev/bitmapex.cxx | 4 vcl/source/outdev/transparent.cxx | 4 23 files changed, 202 insertions(+), 87 deletions(-)
New commits: commit 997a01dfa4ca72d75440e5202bf5419bcc295728 Author: Noel Grandin <[email protected]> AuthorDate: Thu Aug 28 14:03:30 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Thu Aug 28 18:21:56 2025 +0200 BitmapEx->Bitmap in BmpExchangeFnc now that Bitmap can handle transparency Change-Id: I224e581dabeee833b8b9bd0493aaaf3ecc47edad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190329 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/include/vcl/gdimtf.hxx b/include/vcl/gdimtf.hxx index ce0c912b860d..5e67ec86e5ff 100644 --- a/include/vcl/gdimtf.hxx +++ b/include/vcl/gdimtf.hxx @@ -31,6 +31,7 @@ class OutputDevice; class MetaAction; class Color; +class Bitmap; class BitmapEx; namespace tools { class Polygon; @@ -48,7 +49,7 @@ enum class MtfConversion typedef Color (*ColorExchangeFnc)( const Color& rColor, const void* pColParam ); -typedef BitmapEx (*BmpExchangeFnc)( const BitmapEx& rBmpEx, const void* pBmpParam ); +typedef Bitmap (*BmpExchangeFnc)( const Bitmap& rBmp, const void* pBmpParam ); class VCL_DLLPUBLIC GDIMetaFile final { @@ -70,16 +71,16 @@ private: SAL_DLLPRIVATE static Color ImplColAdjustFnc( const Color& rColor, const void* pColParam ); - SAL_DLLPRIVATE static BitmapEx ImplBmpAdjustFnc( const BitmapEx& rBmpEx, const void* pBmpParam ); + SAL_DLLPRIVATE static Bitmap ImplBmpAdjustFnc( const Bitmap& rBmp, const void* pBmpParam ); SAL_DLLPRIVATE static Color ImplColConvertFnc( const Color& rColor, const void* pColParam ); - SAL_DLLPRIVATE static BitmapEx ImplBmpConvertFnc( const BitmapEx& rBmpEx, const void* pBmpParam ); + SAL_DLLPRIVATE static Bitmap ImplBmpConvertFnc( const Bitmap& rBmp, const void* pBmpParam ); SAL_DLLPRIVATE static Color ImplColMonoFnc( const Color& rColor, const void* pColParam ); - SAL_DLLPRIVATE static BitmapEx ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpParam ); + SAL_DLLPRIVATE static Bitmap ImplBmpMonoFnc( const Bitmap& rBmp, const void* pBmpParam ); SAL_DLLPRIVATE static Color ImplColReplaceFnc( const Color& rColor, const void* pColParam ); - SAL_DLLPRIVATE static BitmapEx ImplBmpReplaceFnc( const BitmapEx& rBmpEx, const void* pBmpParam ); + SAL_DLLPRIVATE static Bitmap ImplBmpReplaceFnc( const Bitmap& rBmp, const void* pBmpParam ); SAL_DLLPRIVATE void ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pColParam, BmpExchangeFnc pFncBmp, const void* pBmpParam ); diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index cea9af4e6c88..aa4d4fd41d40 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -1725,10 +1725,10 @@ Color GDIMetaFile::ImplColAdjustFnc( const Color& rColor, const void* pColParam } -BitmapEx GDIMetaFile::ImplBmpAdjustFnc( const BitmapEx& rBmpEx, const void* pBmpParam ) +Bitmap GDIMetaFile::ImplBmpAdjustFnc( const Bitmap& rBmp, const void* pBmpParam ) { const ImplBmpAdjustParam* p = static_cast<const ImplBmpAdjustParam*>(pBmpParam); - BitmapEx aRet( rBmpEx ); + Bitmap aRet( rBmp ); aRet.Adjust( p->nLuminancePercent, p->nContrastPercent, p->nChannelRPercent, p->nChannelGPercent, p->nChannelBPercent, @@ -1747,9 +1747,9 @@ Color GDIMetaFile::ImplColConvertFnc( const Color& rColor, const void* pColParam return Color( ColorAlpha, rColor.GetAlpha(), cLum, cLum, cLum ); } -BitmapEx GDIMetaFile::ImplBmpConvertFnc( const BitmapEx& rBmpEx, const void* pBmpParam ) +Bitmap GDIMetaFile::ImplBmpConvertFnc( const Bitmap& rBmp, const void* pBmpParam ) { - BitmapEx aRet( rBmpEx ); + Bitmap aRet( rBmp ); aRet.Convert( static_cast<const ImplBmpConvertParam*>(pBmpParam)->eConversion ); @@ -1761,20 +1761,20 @@ Color GDIMetaFile::ImplColMonoFnc( const Color&, const void* pColParam ) return static_cast<const ImplColMonoParam*>(pColParam)->aColor; } -BitmapEx GDIMetaFile::ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpParam ) +Bitmap GDIMetaFile::ImplBmpMonoFnc( const Bitmap& rBmp, const void* pBmpParam ) { BitmapPalette aPal( 3 ); aPal[ 0 ] = COL_BLACK; aPal[ 1 ] = COL_WHITE; aPal[ 2 ] = static_cast<const ImplBmpMonoParam*>(pBmpParam)->aColor; - Bitmap aBmp(rBmpEx.GetSizePixel(), vcl::PixelFormat::N8_BPP, &aPal); + Bitmap aBmp(rBmp.GetSizePixel(), vcl::PixelFormat::N8_BPP, &aPal); aBmp.Erase( static_cast<const ImplBmpMonoParam*>(pBmpParam)->aColor ); - if( rBmpEx.IsAlpha() ) - return BitmapEx( aBmp, rBmpEx.GetAlphaMask() ); + if( rBmp.HasAlpha() ) + return Bitmap(BitmapEx( aBmp, rBmp.CreateAlphaMask() )); else - return BitmapEx( aBmp ); + return aBmp; } Color GDIMetaFile::ImplColReplaceFnc( const Color& rColor, const void* pColParam ) @@ -1797,12 +1797,12 @@ Color GDIMetaFile::ImplColReplaceFnc( const Color& rColor, const void* pColParam return rColor; } -BitmapEx GDIMetaFile::ImplBmpReplaceFnc( const BitmapEx& rBmpEx, const void* pBmpParam ) +Bitmap GDIMetaFile::ImplBmpReplaceFnc( const Bitmap& rBmp, const void* pBmpParam ) { const ImplBmpReplaceParam* p = static_cast<const ImplBmpReplaceParam*>(pBmpParam); - BitmapEx aRet( rBmpEx ); + Bitmap aRet( rBmp ); - aRet.Replace( p->pSrcCols, p->pDstCols, p->nCount ); + aRet.Replace( p->pSrcCols, p->pDstCols, p->nCount, nullptr ); return aRet; } @@ -1912,7 +1912,7 @@ void GDIMetaFile::ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pCol aWall.SetColor( pFncCol( aWall.GetColor(), pColParam ) ); if( aWall.IsBitmap() ) - aWall.SetBitmap( Bitmap(pFncBmp( BitmapEx(aWall.GetBitmap()), pBmpParam )) ); + aWall.SetBitmap( pFncBmp( aWall.GetBitmap(), pBmpParam ) ); if( aWall.IsGradient() ) { @@ -1939,7 +1939,7 @@ void GDIMetaFile::ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pCol { MetaBmpScaleAction* pAct = static_cast<MetaBmpScaleAction*>(pAction); aMtf.push_back( new MetaBmpScaleAction( pAct->GetPoint(), pAct->GetSize(), - pFncBmp( BitmapEx(pAct->GetBitmap()), pBmpParam ).GetBitmap() ) ); + pFncBmp( pAct->GetBitmap(), pBmpParam ).CreateColorBitmap() ) ); } break; @@ -1948,7 +1948,7 @@ void GDIMetaFile::ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pCol MetaBmpScalePartAction* pAct = static_cast<MetaBmpScalePartAction*>(pAction); aMtf.push_back( new MetaBmpScalePartAction( pAct->GetDestPoint(), pAct->GetDestSize(), pAct->GetSrcPoint(), pAct->GetSrcSize(), - pFncBmp( BitmapEx(pAct->GetBitmap()), pBmpParam ).GetBitmap() ) + pFncBmp( pAct->GetBitmap(), pBmpParam ).CreateColorBitmap() ) ); } break; @@ -1957,7 +1957,7 @@ void GDIMetaFile::ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pCol { MetaBmpExScaleAction* pAct = static_cast<MetaBmpExScaleAction*>(pAction); aMtf.push_back( new MetaBmpExScaleAction( pAct->GetPoint(), pAct->GetSize(), - pFncBmp( pAct->GetBitmapEx(), pBmpParam ) ) + BitmapEx(pFncBmp( Bitmap(pAct->GetBitmapEx()), pBmpParam )) ) ); } break; @@ -1967,7 +1967,7 @@ void GDIMetaFile::ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pCol MetaBmpExScalePartAction* pAct = static_cast<MetaBmpExScalePartAction*>(pAction); aMtf.push_back( new MetaBmpExScalePartAction( pAct->GetDestPoint(), pAct->GetDestSize(), pAct->GetSrcPoint(), pAct->GetSrcSize(), - pFncBmp( pAct->GetBitmapEx(), pBmpParam ) ) + BitmapEx(pFncBmp( Bitmap(pAct->GetBitmapEx()), pBmpParam )) ) ); } break; commit 0680ba025822c20496b747c47b4dd8e1e43405ed Author: Noel Grandin <[email protected]> AuthorDate: Thu Aug 28 14:19:21 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Thu Aug 28 18:21:42 2025 +0200 BitmapEx->Bitmap in MetaBmpExAction now that Bitmap supports transparency Note that the SVM unit test changed because we no longer store some bitmaps as an 8-bit palette color layer and an 8-bit alpha layer. When those pass through Bitmap, they get converted to a 32-bit bitmap. Change-Id: Icbb30e291a7ed5c53319876637ae25e88a97d90d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190330 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx index 9f5003ba12ce..04b8dec944a8 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -2188,7 +2188,7 @@ namespace cppcanvas::internal std::shared_ptr<Action> pBmpAction( internal::BitmapActionFactory::createBitmapAction( - Bitmap(pAct->GetBitmapEx()), + pAct->GetBitmap(), rStates.getState().mapModeTransform * vcl::unotools::b2DPointFromPoint( pAct->GetPoint() ), rCanvas, diff --git a/drawinglayer/source/tools/wmfemfhelper.cxx b/drawinglayer/source/tools/wmfemfhelper.cxx index ec9ba943dc93..9e44dcfecadf 100644 --- a/drawinglayer/source/tools/wmfemfhelper.cxx +++ b/drawinglayer/source/tools/wmfemfhelper.cxx @@ -1952,9 +1952,9 @@ namespace wmfemfhelper { /** CHECKED, WORKS WELL: Simply same as MetaActionType::BMP */ const MetaBmpExAction* pA = static_cast<const MetaBmpExAction*>(pAction); - const BitmapEx& rBitmapEx = pA->GetBitmapEx(); + const Bitmap& rBitmap = pA->GetBitmap(); - createBitmapPrimitive(Bitmap(rBitmapEx), pA->GetPoint(), rTargetHolders.Current(), rPropertyHolders.Current()); + createBitmapPrimitive(rBitmap, pA->GetPoint(), rTargetHolders.Current(), rPropertyHolders.Current()); break; } diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index dc0436422f0e..7b255e5f8c07 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -3909,9 +3909,9 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, { const MetaBmpExAction* pA = static_cast<const MetaBmpExAction*>(pAction); - ImplWriteBmp( pA->GetBitmapEx(), - pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmapEx().GetSizePixel() ), - Point(), pA->GetBitmapEx().GetSizePixel(), pxShape ); + ImplWriteBmp( BitmapEx(pA->GetBitmap()), + pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmap().GetSizePixel() ), + Point(), pA->GetBitmap().GetSizePixel(), pxShape ); } } break; diff --git a/include/vcl/metaact.hxx b/include/vcl/metaact.hxx index d9bd66c9db11..ce6c345e4c8e 100644 --- a/include/vcl/metaact.hxx +++ b/include/vcl/metaact.hxx @@ -787,7 +787,7 @@ class VCL_DLLPUBLIC MetaBmpExAction final : public MetaAction { private: - BitmapEx maBmpEx; + Bitmap maBmp; Point maPt; public: @@ -802,16 +802,16 @@ public: SAL_DLLPRIVATE virtual void Execute( OutputDevice* pOut ) override; SAL_DLLPRIVATE virtual rtl::Reference<MetaAction> Clone() const override; - MetaBmpExAction( const Point& rPt, const BitmapEx& rBmpEx ); + MetaBmpExAction( const Point& rPt, const Bitmap& rBmp ); SAL_DLLPRIVATE virtual void Move( tools::Long nHorzMove, tools::Long nVertMove ) override; SAL_DLLPRIVATE virtual void Scale( double fScaleX, double fScaleY ) override; - const BitmapEx& GetBitmapEx() const { return maBmpEx; } + const Bitmap& GetBitmap() const { return maBmp; } const Point& GetPoint() const { return maPt; } - void SetBitmapEx(const BitmapEx& rBmpEx) { maBmpEx = rBmpEx; } + void SetBitmap(const Bitmap& rBmp) { maBmp = rBmp; } void SetPoint(const Point& rPt) { maPt = rPt; } - bool IsTransparent() const override { return GetBitmapEx().IsAlpha(); } + bool IsTransparent() const override { return GetBitmap().HasAlpha(); } }; class VCL_DLLPUBLIC MetaBmpExScaleAction final : public MetaAction diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index 5f4f6f5abc9c..da293e013bb8 100644 --- a/sd/source/ui/view/sdview3.cxx +++ b/sd/source/ui/view/sdview3.cxx @@ -214,7 +214,7 @@ bool View::InsertMetaFile( const TransferableDataHelper& rDataHelper, const Poin { MetaBmpExAction* pBmpExAction = dynamic_cast< MetaBmpExAction* >( pAction ); if( pBmpExAction ) - aGraphic = Graphic(Bitmap(pBmpExAction->GetBitmapEx()) ); + aGraphic = Graphic(pBmpExAction->GetBitmap()); } break; case MetaActionType::BMPEXSCALE: diff --git a/sfx2/source/doc/SfxRedactionHelper.cxx b/sfx2/source/doc/SfxRedactionHelper.cxx index 8e9b5f69dce2..4b748bb55e95 100644 --- a/sfx2/source/doc/SfxRedactionHelper.cxx +++ b/sfx2/source/doc/SfxRedactionHelper.cxx @@ -530,7 +530,7 @@ void SfxRedactionHelper::searchImagesInMetaFile( { MetaBmpExAction* pAction = static_cast<MetaBmpExAction*>(pCurrAct); aDestPt = pAction->GetPoint(); - aDestSz = pAction->GetBitmapEx().GetSizePixel(); + aDestSz = pAction->GetBitmap().GetSizePixel(); break; } diff --git a/slideshow/source/engine/shapes/gdimtftools.cxx b/slideshow/source/engine/shapes/gdimtftools.cxx index c476c4f56898..8ecdba8d3b6d 100644 --- a/slideshow/source/engine/shapes/gdimtftools.cxx +++ b/slideshow/source/engine/shapes/gdimtftools.cxx @@ -135,7 +135,7 @@ public: ::Bitmap aBmp( aGraphic.GetBitmap() ); - xMtf->AddAction( new MetaBmpExAction( Point(), BitmapEx(aBmp) ) ); + xMtf->AddAction( new MetaBmpExAction( Point(), aBmp ) ); xMtf->SetPrefSize( aBmp.GetPrefSize() ); xMtf->SetPrefMapMode( aBmp.GetPrefMapMode() ); @@ -375,11 +375,11 @@ bool getAnimationFromGraphic( VectorOfMtfAnimationFrames& o_rFrames, AlphaMask aAlphaMask(pVDevMask->GetBitmap(aEmptyPoint, aAnimSize)); pMtf->AddAction( new MetaBmpExAction( aEmptyPoint, - BitmapEx( + Bitmap(BitmapEx( pVDev->GetBitmap( aEmptyPoint, aAnimSize ), - aAlphaMask))); + aAlphaMask)))); } else { @@ -387,11 +387,11 @@ bool getAnimationFromGraphic( VectorOfMtfAnimationFrames& o_rFrames, aAlphaMask.Invert(); // convert from transparency to alpha pMtf->AddAction( new MetaBmpExAction( aEmptyPoint, - BitmapEx( + Bitmap(BitmapEx( pVDev->GetBitmap( aEmptyPoint, aAnimSize ), - aAlphaMask))); + aAlphaMask)))); } mnLoadedFrames = i+1; } diff --git a/svx/source/dialog/_bmpmask.cxx b/svx/source/dialog/_bmpmask.cxx index fc71042fd3a6..a5110a714324 100644 --- a/svx/source/dialog/_bmpmask.cxx +++ b/svx/source/dialog/_bmpmask.cxx @@ -841,9 +841,9 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf ) case MetaActionType::BMPEX: { MetaBmpExAction* pAct = static_cast<MetaBmpExAction*>(pAction); - const BitmapEx aBmpEx( Mask( Bitmap(pAct->GetBitmapEx()) ).GetBitmap() ); + const Bitmap aBmp( Mask( pAct->GetBitmap() ).GetBitmap() ); - pAct = new MetaBmpExAction( pAct->GetPoint(), aBmpEx ); + pAct = new MetaBmpExAction( pAct->GetPoint(), aBmp ); aMtf.AddAction( pAct ); } break; diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index 5f44de53a7ee..2e90ad200a1e 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -1129,11 +1129,11 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction const & rAct) void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExAction const & rAct) { - tools::Rectangle aRect(rAct.GetPoint(),rAct.GetBitmapEx().GetSizePixel()); + tools::Rectangle aRect(rAct.GetPoint(),rAct.GetBitmap().GetSizePixel()); aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 ); rtl::Reference<SdrGrafObj> pGraf = new SdrGrafObj( *mpModel, - Bitmap(rAct.GetBitmapEx()), + rAct.GetBitmap(), aRect); // This action is not creating line and fill, set directly, do not use SetAttributes(..) diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx index fd70153ce485..ba8f4188c76e 100644 --- a/vcl/qa/cppunit/svm/svmtest.cxx +++ b/vcl/qa/cppunit/svm/svmtest.cxx @@ -1067,11 +1067,11 @@ void SvmTest::checkBitmapExs(const GDIMetaFile& rMetaFile, bool bIsSvmFile) #else u"469f0820", // atypical RGBA little-endian config #endif - u"839e8cce", - u"236aaf55", // 1-bit - u"2949ccc7", // 4-bit color bitmap - same as 8-bit color bitmap - u"2949ccc7", - u"e5df8aad", + u"a17eb609", + u"7bd5c66f", // 1-bit + u"ec307070", // 4-bit color bitmap - same as 8-bit color bitmap + u"ec307070", + u"b6d8e2d5", #endif }; @@ -1080,7 +1080,7 @@ void SvmTest::checkBitmapExs(const GDIMetaFile& rMetaFile, bool bIsSvmFile) u"26bdebd04e5b18d685cea04982179e273ee3b659", u"f4f52df6ef965a2f0fbccbe6aca35ba3457cf9d5", u"7c953a06d34bbd38897f950d595df2880dbb0f75", - u"ca3e5cdde1c395e1ee76d339a5bf6e46fbac3249", + u"7b51ea0cc5da3bbaf9b9d3dc1cde8e5fa69dbdf2", u"8a1ebc46f890eb0879464c6e293bffd4ce7fadc0", // 1-bit u"23611fc9f484c23e45bbd457730adb8ab5355509", // 4-bit color bitmap - same as 8-bit color bitmap u"23611fc9f484c23e45bbd457730adb8ab5355509", @@ -1105,7 +1105,7 @@ void SvmTest::checkBitmapExs(const GDIMetaFile& rMetaFile, bool bIsSvmFile) {"x", u"6"}, {"y", u"6"}, {"crc", aExpectedCRC[3]}, {"transparenttype", u"bitmap"}, {"contentchecksum", aExpectedContentChecksum[3]} }); assertXPathAttrs(pDoc, "/metafile/bmpex[3]", { - {"x", u"0"}, {"y", u"6"}, {"transparenttype", u"bitmap"}, {"contentchecksum", aExpectedContentChecksum[4]}, {"pixelformat", u"8BPP"} + {"x", u"0"}, {"y", u"6"}, {"transparenttype", u"bitmap"}, {"contentchecksum", aExpectedContentChecksum[4]}, {"pixelformat", u"24BPP"} }); if (!bIsSvmFile) { @@ -1114,13 +1114,13 @@ void SvmTest::checkBitmapExs(const GDIMetaFile& rMetaFile, bool bIsSvmFile) }); } assertXPathAttrs(pDoc, "/metafile/bmpex[4]", { - {"x", u"2"}, {"y", u"6"}, {"crc", aExpectedCRC[5]}, {"transparenttype", u"bitmap"}, {"contentchecksum", aExpectedContentChecksum[5]}, {"pixelformat", u"8BPP"} + {"x", u"2"}, {"y", u"6"}, {"crc", aExpectedCRC[5]}, {"transparenttype", u"bitmap"}, {"contentchecksum", aExpectedContentChecksum[5]}, {"pixelformat", u"24BPP"} }); assertXPathAttrs(pDoc, "/metafile/bmpex[5]", { - {"x", u"0"}, {"y", u"8"}, {"crc", aExpectedCRC[6]}, {"transparenttype", u"bitmap"}, {"contentchecksum", aExpectedContentChecksum[6]}, {"pixelformat", u"8BPP"} + {"x", u"0"}, {"y", u"8"}, {"crc", aExpectedCRC[6]}, {"transparenttype", u"bitmap"}, {"contentchecksum", aExpectedContentChecksum[6]}, {"pixelformat", u"24BPP"} }); assertXPathAttrs(pDoc, "/metafile/bmpex[6]", { - {"x", u"2"}, {"y", u"8"}, {"crc", aExpectedCRC[7]}, {"transparenttype", u"bitmap"}, {"contentchecksum", aExpectedContentChecksum[7]}, {"pixelformat", u"8BPP"} + {"x", u"2"}, {"y", u"8"}, {"crc", aExpectedCRC[7]}, {"transparenttype", u"bitmap"}, {"contentchecksum", aExpectedContentChecksum[7]}, {"pixelformat", u"24BPP"} }); #else (void)bIsSvmFile; diff --git a/vcl/source/filter/eps/eps.cxx b/vcl/source/filter/eps/eps.cxx index 278ed22635f5..edcdf46fe21a 100644 --- a/vcl/source/filter/eps/eps.cxx +++ b/vcl/source/filter/eps/eps.cxx @@ -815,11 +815,11 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) case MetaActionType::BMPEX : { - BitmapEx aBitmapEx( static_cast<MetaBmpExAction*>(pMA)->GetBitmapEx() ); - Bitmap aBitmap( aBitmapEx.GetBitmap() ); + Bitmap aBitmapEx( static_cast<MetaBmpExAction*>(pMA)->GetBitmap() ); + Bitmap aBitmap( aBitmapEx.CreateColorBitmap() ); if ( mbGrayScale ) aBitmap.Convert( BmpConversion::N8BitGreys ); - const AlphaMask& aMask( aBitmapEx.GetAlphaMask() ); + const AlphaMask aMask( aBitmapEx.CreateAlphaMask() ); Point aPoint( static_cast<const MetaBmpExAction*>(pMA)->GetPoint() ); Size aSize( rVDev.PixelToLogic( aBitmap.GetSizePixel() ) ); ImplBmp( &aBitmap, &aMask, aPoint, aSize.Width(), aSize.Height() ); diff --git a/vcl/source/filter/svm/SvmReader.cxx b/vcl/source/filter/svm/SvmReader.cxx index 01a9dd30d6ea..250b46830e7f 100644 --- a/vcl/source/filter/svm/SvmReader.cxx +++ b/vcl/source/filter/svm/SvmReader.cxx @@ -937,14 +937,14 @@ rtl::Reference<MetaAction> SvmReader::BmpExHandler() rtl::Reference<MetaBmpExAction> pAction(new MetaBmpExAction); VersionCompatRead aCompat(mrStream); - BitmapEx aBmpEx; - ReadDIBBitmapEx(aBmpEx, mrStream); + Bitmap aBmp; + ReadDIBBitmapEx(aBmp, mrStream); TypeSerializer aSerializer(mrStream); Point aPoint; aSerializer.readPoint(aPoint); pAction->SetPoint(aPoint); - pAction->SetBitmapEx(aBmpEx); + pAction->SetBitmap(aBmp); return pAction; } diff --git a/vcl/source/filter/svm/SvmWriter.cxx b/vcl/source/filter/svm/SvmWriter.cxx index 0720d4b27f9c..2e141e2f407c 100644 --- a/vcl/source/filter/svm/SvmWriter.cxx +++ b/vcl/source/filter/svm/SvmWriter.cxx @@ -171,7 +171,7 @@ BitmapChecksum SvmWriter::GetChecksum(const GDIMetaFile& rMetaFile) ShortToSVBT16(static_cast<sal_uInt16>(pAct->GetType()), aBT16); nCrc = rtl_crc32(nCrc, aBT16, 2); - BCToBCOA(pAct->GetBitmapEx().GetChecksum(), aBCOA); + BCToBCOA(pAct->GetBitmap().GetChecksum(), aBCOA); nCrc = rtl_crc32(nCrc, aBCOA, BITMAP_CHECKSUM_SIZE); Int32ToSVBT32(pAct->GetPoint().X(), aBT32); @@ -1103,11 +1103,11 @@ void SvmWriter::BmpScalePartHandler(const MetaBmpScalePartAction* pAction) void SvmWriter::BmpExHandler(const MetaBmpExAction* pAction) { - if (!pAction->GetBitmapEx().GetBitmap().IsEmpty()) + if (!pAction->GetBitmap().CreateColorBitmap().IsEmpty()) { mrStream.WriteUInt16(static_cast<sal_uInt16>(pAction->GetType())); VersionCompatWrite aCompat(mrStream, 1); - WriteDIBBitmapEx(pAction->GetBitmapEx(), mrStream); + WriteDIBBitmapEx(pAction->GetBitmap(), mrStream); TypeSerializer aSerializer(mrStream); aSerializer.writePoint(pAction->GetPoint()); } diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index 3572980f20b5..ce4bd562a565 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -1288,8 +1288,8 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case MetaActionType::BMPEX: { const MetaBmpExAction* pA = static_cast<const MetaBmpExAction *>(pAction); - Bitmap aBmp( pA->GetBitmapEx().GetBitmap() ); - AlphaMask aMsk( pA->GetBitmapEx().GetAlphaMask() ); + Bitmap aBmp( pA->GetBitmap().CreateColorBitmap() ); + AlphaMask aMsk( pA->GetBitmap().CreateAlphaMask() ); if( !aMsk.IsEmpty() ) { diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx index 6f42017321ed..3558b60057cb 100644 --- a/vcl/source/filter/wmf/wmfwr.cxx +++ b/vcl/source/filter/wmf/wmfwr.cxx @@ -1244,8 +1244,8 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) case MetaActionType::BMPEX: { const MetaBmpExAction* pA = static_cast<const MetaBmpExAction *>(pMA); - Bitmap aBmp( pA->GetBitmapEx().GetBitmap() ); - AlphaMask aMsk( pA->GetBitmapEx().GetAlphaMask() ); + Bitmap aBmp( pA->GetBitmap().CreateColorBitmap() ); + AlphaMask aMsk( pA->GetBitmap().CreateAlphaMask() ); if( !aMsk.IsEmpty() ) { diff --git a/vcl/source/gdi/gdimetafiletools.cxx b/vcl/source/gdi/gdimetafiletools.cxx index 40d7817afcb0..998dea176b9a 100644 --- a/vcl/source/gdi/gdimetafiletools.cxx +++ b/vcl/source/gdi/gdimetafiletools.cxx @@ -231,6 +231,120 @@ namespace return true; } + bool handleBitmapContent( + const basegfx::B2DPolyPolygon& rClip, + const Point& rPoint, + const Size& rSize, + const Bitmap& rBitmap, + GDIMetaFile& rTarget) + { + if(!rSize.Width() || !rSize.Height() || rBitmap.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(rBitmap.GetSizePixel()); + ScopedVclPtrInstance< VirtualDevice > aVDev; + + aVDev->SetOutputSizePixel(aSizePixel); + aVDev->EnableMapMode(false); + aVDev->SetFillColor( COL_WHITE); + aVDev->SetLineColor(); + + if(rBitmap.HasAlpha()) + { + // use given alpha channel + aVDev->DrawBitmap(Point(0, 0), rBitmap.CreateAlphaMask().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(rBitmap.GetPrefSize()); + aAlpha.SetPrefMapMode(rBitmap.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())), + BitmapEx(rBitmap.CreateColorBitmap(), aAlpha))); + + return true; + } + void addSvtGraphicStroke(const SvtGraphicStroke& rStroke, GDIMetaFile& rTarget) { // write SvtGraphicFill @@ -705,26 +819,26 @@ void clipMetafileContentAgainstOwnRegions(GDIMetaFile& rSource) case MetaActionType::BMPEX : { const MetaBmpExAction* pA = static_cast< const MetaBmpExAction* >(pAction); - const BitmapEx& rBitmapEx = pA->GetBitmapEx(); + const Bitmap& rBitmap = pA->GetBitmap(); // the logical size depends on the PrefSize of the given bitmap in // combination with the current MapMode - Size aLogicalSize(rBitmapEx.GetPrefSize()); + Size aLogicalSize(rBitmap.GetPrefSize()); - if(MapUnit::MapPixel == rBitmapEx.GetPrefMapMode().GetMapUnit()) + if(MapUnit::MapPixel == rBitmap.GetPrefMapMode().GetMapUnit()) { aLogicalSize = Application::GetDefaultDevice()->PixelToLogic(aLogicalSize, aMapModes.back()); } else { - aLogicalSize = OutputDevice::LogicToLogic(aLogicalSize, rBitmapEx.GetPrefMapMode(), aMapModes.back()); + aLogicalSize = OutputDevice::LogicToLogic(aLogicalSize, rBitmap.GetPrefMapMode(), aMapModes.back()); } bDone = handleBitmapContent( aClips.back(), pA->GetPoint(), aLogicalSize, - rBitmapEx, + rBitmap, aTarget); break; } diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 3a58ce2b6fc6..cea9af4e6c88 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -1625,7 +1625,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference ) const case MetaActionType::BMPEX: { MetaBmpExAction* pAct = static_cast<MetaBmpExAction*>(pAction); - tools::Rectangle aRect( pAct->GetPoint(), aMapVDev->PixelToLogic( pAct->GetBitmapEx().GetSizePixel() ) ); + tools::Rectangle aRect( pAct->GetPoint(), aMapVDev->PixelToLogic( pAct->GetBitmap().GetSizePixel() ) ); ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -2225,7 +2225,7 @@ sal_uLong GDIMetaFile::GetSizeBytes() const case MetaActionType::BMPSCALE: nSizeBytes += static_cast<MetaBmpScaleAction*>( pAction )->GetBitmap().GetSizeBytes(); break; case MetaActionType::BMPSCALEPART: nSizeBytes += static_cast<MetaBmpScalePartAction*>( pAction )->GetBitmap().GetSizeBytes(); break; - case MetaActionType::BMPEX: nSizeBytes += static_cast<MetaBmpExAction*>( pAction )->GetBitmapEx().GetSizeBytes(); break; + case MetaActionType::BMPEX: nSizeBytes += static_cast<MetaBmpExAction*>( pAction )->GetBitmap().GetSizeBytes(); break; case MetaActionType::BMPEXSCALE: nSizeBytes += static_cast<MetaBmpExScaleAction*>( pAction )->GetBitmapEx().GetSizeBytes(); break; case MetaActionType::BMPEXSCALEPART: nSizeBytes += static_cast<MetaBmpExScalePartAction*>( pAction )->GetBitmapEx().GetSizeBytes(); break; diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 384817cc0804..e2a75e38b50e 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -1067,15 +1067,15 @@ MetaBmpExAction::MetaBmpExAction() : MetaBmpExAction::~MetaBmpExAction() {} -MetaBmpExAction::MetaBmpExAction( const Point& rPt, const BitmapEx& rBmpEx ) : +MetaBmpExAction::MetaBmpExAction( const Point& rPt, const Bitmap& rBmp ) : MetaAction ( MetaActionType::BMPEX ), - maBmpEx ( rBmpEx ), + maBmp ( rBmp ), maPt ( rPt ) {} void MetaBmpExAction::Execute( OutputDevice* pOut ) { - pOut->DrawBitmapEx( maPt, maBmpEx ); + pOut->DrawBitmapEx( maPt, maBmp ); } rtl::Reference<MetaAction> MetaBmpExAction::Clone() const diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx index 24cd96ce5964..6c418c0f362b 100644 --- a/vcl/source/gdi/mtfxmldump.cxx +++ b/vcl/source/gdi/mtfxmldump.cxx @@ -1004,8 +1004,8 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r auto pMeta = static_cast<MetaBmpExAction*>(pAction); rWriter.startElement(sCurrentElementTag); writePoint(rWriter, pMeta->GetPoint()); - Bitmap aBitmap = pMeta->GetBitmapEx().GetBitmap(); - rWriter.attribute("transparenttype", convertBitmapExTransparentType(pMeta->GetBitmapEx())); + Bitmap aBitmap = pMeta->GetBitmap().CreateColorBitmap(); + rWriter.attribute("transparenttype", convertBitmapTransparentType(pMeta->GetBitmap())); writeBitmap(rWriter, aBitmap); rWriter.endElement(); } diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index 0c8b6fc19322..40a1a4154c78 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -764,11 +764,11 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa case MetaActionType::BMPEX: { const MetaBmpExAction* pA = static_cast<const MetaBmpExAction*>(pAction); - BitmapEx aBitmapEx( pA->GetBitmapEx() ); - Size aSize( OutputDevice::LogicToLogic( aBitmapEx.GetPrefSize(), - aBitmapEx.GetPrefMapMode(), pDummyVDev->GetMapMode() ) ); + Bitmap aBitmap( pA->GetBitmap() ); + Size aSize( OutputDevice::LogicToLogic( aBitmap.GetPrefSize(), + aBitmap.GetPrefMapMode(), pDummyVDev->GetMapMode() ) ); Graphic aGraphic = i_pOutDevData ? i_pOutDevData->GetCurrentGraphic() : Graphic(); - implWriteBitmapEx( pA->GetPoint(), aSize, Bitmap(aBitmapEx), aGraphic, pDummyVDev, i_rContext ); + implWriteBitmapEx( pA->GetPoint(), aSize, aBitmap, aGraphic, pDummyVDev, i_rContext ); } break; diff --git a/vcl/source/outdev/bitmapex.cxx b/vcl/source/outdev/bitmapex.cxx index fd97b1afe415..305fd442152b 100644 --- a/vcl/source/outdev/bitmapex.cxx +++ b/vcl/source/outdev/bitmapex.cxx @@ -172,7 +172,7 @@ void OutputDevice::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, switch(nAction) { case MetaActionType::BMPEX: - mpMetaFile->AddAction(new MetaBmpExAction(rDestPt, aBmpEx)); + mpMetaFile->AddAction(new MetaBmpExAction(rDestPt, Bitmap(aBmpEx))); break; case MetaActionType::BMPEXSCALE: @@ -232,7 +232,7 @@ void OutputDevice::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, switch(nAction) { case MetaActionType::BMPEX: - mpMetaFile->AddAction(new MetaBmpExAction(rDestPt, aBmpEx)); + mpMetaFile->AddAction(new MetaBmpExAction(rDestPt, Bitmap(aBmpEx))); break; case MetaActionType::BMPEXSCALE: diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx index 9310182d611f..0e97fd1edcb1 100644 --- a/vcl/source/outdev/transparent.cxx +++ b/vcl/source/outdev/transparent.cxx @@ -820,7 +820,7 @@ void ImplConvertTransparentAction( GDIMetaFile& o_rMtf, switch (rAct.GetType()) { case MetaActionType::BMPEX: - aBmpEx = static_cast<const MetaBmpExAction&>(rAct).GetBitmapEx(); + aBmpEx = static_cast<const MetaBmpExAction&>(rAct).GetBitmap(); break; case MetaActionType::BMPEXSCALE: @@ -1088,7 +1088,7 @@ tools::Rectangle ImplCalcActionBounds( const MetaAction& rAct, const OutputDevic case MetaActionType::BMPEX: aActionBounds = tools::Rectangle( static_cast<const MetaBmpExAction&>(rAct).GetPoint(), - rOut.PixelToLogic( static_cast<const MetaBmpExAction&>(rAct).GetBitmapEx().GetSizePixel() ) ); + rOut.PixelToLogic( static_cast<const MetaBmpExAction&>(rAct).GetBitmap().GetSizePixel() ) ); break; case MetaActionType::BMPEXSCALE:
