diff options
author | Armin Le Grand (Allotropia) <Armin.Le.Grand@me.com> | 2022-01-31 19:44:19 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2022-02-02 09:43:10 +0100 |
commit | 4d535c4f867d86d40786788e5e5c9fd061a65673 (patch) | |
tree | 9611377bf20a0d9ac46ffc1101f769ae0e1f7ac3 | |
parent | 60a1f07049a817d4d3d7beb6c9b9da2571e2463b (diff) |
tdf#126319 Corrected bitmap creation from metafile
The conversion from Metafile to Bitmap in GraphicExporter
is based on metafiles which does just not deliver enough
precision when getting the bounds to do the correct size
calculation for the target Bitmap.
So I changed that to use Primitive functionality what
produces better data. That old fix/correction itself was
based on hairlines only which is anyways no longer
sufficient since LO uses less hairlines nowadays, what
is good in general (They are a relic of non-AA times
when it was not possible to paint/work with lines taller
than one pixel).
Thus, cases need to be solved more generic based on
better data. It would also be good to change this
to primitives completely, but that is too much for now.
Change-Id: I71bd136b106ef8ff3ba51458c46df08269773c01
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129235
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
-rw-r--r-- | include/vcl/gdimtf.hxx | 2 | ||||
-rw-r--r-- | svx/source/unodraw/UnoGraphicExporter.cxx | 96 | ||||
-rw-r--r-- | vcl/source/gdi/gdimtf.cxx | 100 | ||||
-rw-r--r-- | vcl/source/gdi/impgraph.cxx | 27 |
4 files changed, 80 insertions, 145 deletions
diff --git a/include/vcl/gdimtf.hxx b/include/vcl/gdimtf.hxx index 614d77369d1f..f8637675482d 100644 --- a/include/vcl/gdimtf.hxx +++ b/include/vcl/gdimtf.hxx @@ -125,7 +125,7 @@ public: * - coordinates of actions will be transformed to preferred mapmode * - the returned rectangle is relative to the preferred mapmode of the metafile */ - tools::Rectangle GetBoundRect( OutputDevice& i_rReference, tools::Rectangle* pHairline = nullptr ) const; + tools::Rectangle GetBoundRect( OutputDevice& i_rReference ) const; void Adjust( short nLuminancePercent, short nContrastPercent, short nChannelRPercent = 0, short nChannelGPercent = 0, diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index 6c158e936684..a91f16ab64f7 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -178,7 +178,7 @@ namespace { /** creates a bitmap that is optionally transparent from a metafile */ - BitmapEx GetBitmapFromMetaFile( const GDIMetaFile& rMtf,bool bIsSelection, const Size* pSize ) + BitmapEx GetBitmapFromMetaFile( const GDIMetaFile& rMtf, const Size* pSize ) { // use new primitive conversion tooling basegfx::B2DRange aRange(basegfx::B2DPoint(0.0, 0.0)); @@ -204,55 +204,7 @@ namespace { aRange.expand(basegfx::B2DPoint(aSize100th.Width(), aSize100th.Height())); } - // get hairline and full bound rect to evtl. correct logic size by the - // equivalent of one pixel to make those visible at right and bottom - tools::Rectangle aHairlineRect; - const tools::Rectangle aRect(rMtf.GetBoundRect(*Application::GetDefaultDevice(), &aHairlineRect)); - - if(!aRect.IsEmpty()) - { - GDIMetaFile aMtf(rMtf); - - if (bIsSelection) - { - // tdf#105998 Correct the Metafile using information from it's real sizes measured - // using rMtf.GetBoundRect above and a copy - const Size aOnePixelInMtf( - Application::GetDefaultDevice()->PixelToLogic( - Size(1, 1), - rMtf.GetPrefMapMode())); - const Size aHalfPixelInMtf( - (aOnePixelInMtf.getWidth() + 1) / 2, - (aOnePixelInMtf.getHeight() + 1) / 2); - - // tdf#126319 take bounds into account individually - const bool bHairlineRight(!aHairlineRect.IsEmpty() && aRect.Right() == aHairlineRect.Right()); - const bool bHairlineBottom(!aHairlineRect.IsEmpty() && aRect.Bottom() == aHairlineRect.Bottom()); - const bool bHairlineLeft(!aHairlineRect.IsEmpty() && aRect.Left() == aHairlineRect.Left()); - const bool bHairlineTop(!aHairlineRect.IsEmpty() && aRect.Top() == aHairlineRect.Top()); - - // tdf#126319 Move the content dependent on Top/Left hairline - aMtf.Move( - (bHairlineLeft ? -aHalfPixelInMtf.getWidth() : aHalfPixelInMtf.getWidth()), - (bHairlineTop ? -aHalfPixelInMtf.getHeight() : aHalfPixelInMtf.getHeight())); - - // Do not Scale, but set the PrefSize. Some levels deeper the - // MetafilePrimitive will add a mapping to the decomposition - // (and possibly a clipping) to map the graphic content to - // a unit coordinate system. - // tdf#126319 Size is the previous already correct size plus one - // pixel if needed (dependent on Righ/Bottom hairline) and the - // already moved half pixel from above - aMtf.SetPrefSize( - Size( - aMtf.GetPrefSize().Width() + (bHairlineRight ? aHalfPixelInMtf.getWidth() : 0), - aMtf.GetPrefSize().Height() + (bHairlineBottom ? aHalfPixelInMtf.getHeight() : 0))); - } - - return convertMetafileToBitmapEx(aMtf, aRange, nMaximumQuadraticPixels); - } - - return BitmapEx(); + return convertMetafileToBitmapEx(rMtf, aRange, nMaximumQuadraticPixels); } Size* CalcSize( sal_Int32 nWidth, sal_Int32 nHeight, const Size& aBoundSize, Size& aOutSize ) @@ -777,7 +729,7 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr if( rSettings.mbTranslucent ) { Size aOutSize; - aGraphic = GetBitmapFromMetaFile( aGraphic.GetGDIMetaFile(), false, CalcSize( rSettings.mnWidth, rSettings.mnHeight, aNewSize, aOutSize ) ); + aGraphic = GetBitmapFromMetaFile( aGraphic.GetGDIMetaFile(), CalcSize( rSettings.mnWidth, rSettings.mnHeight, aNewSize, aOutSize ) ); } } } @@ -901,16 +853,22 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr ScopedVclPtrInstance< VirtualDevice > aOut; // calculate bound rect for all shapes - tools::Rectangle aBound; + // tdf#126319 I did not convert all rendering to primities, + // that would be to much for this fix. But I did so for the + // range calculation to get a valid high quality range. + // Based on that the conversion is reliable. With the BoundRect + // fetched from the Metafile it was just not possible to get the + // examples from the task handled in a way to fit all cases - + // due to bad-quality range data from it. + basegfx::B2DRange aBound; + const drawinglayer::geometry::ViewInformation2D aViewInformation2D; { for( SdrObject* pObj : aShapes ) { - tools::Rectangle aR1(pObj->GetCurrentBoundRect()); - if (aBound.IsEmpty()) - aBound=aR1; - else - aBound.Union(aR1); + drawinglayer::primitive2d::Primitive2DContainer aSequence; + pObj->GetViewContact().getViewIndependentPrimitive2DContainer(aSequence); + aBound.expand(aSequence.getB2DRange(aViewInformation2D)); } } @@ -924,7 +882,20 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr aMtf.Record( aOut ); MapMode aOutMap( aMap ); - aOutMap.SetOrigin( Point( -aBound.Left(), -aBound.Top() ) ); + const Size aOnePixelInMtf( + Application::GetDefaultDevice()->PixelToLogic( + Size(1, 1), + aMap)); + const Size aHalfPixelInMtf( + (aOnePixelInMtf.getWidth() + 1) / 2, + (aOnePixelInMtf.getHeight() + 1) / 2); + + // tdf#126319 Immediately add needed offset to create metafile, + // that avoids to do it later by Metafile::Move what would be expensive + aOutMap.SetOrigin( + Point( + basegfx::fround(-aBound.getMinX() - aHalfPixelInMtf.getWidth()), + basegfx::fround(-aBound.getMinY() - aHalfPixelInMtf.getHeight()) ) ); aOut->SetRelativeMapMode( aOutMap ); sdr::contact::DisplayInfo aDisplayInfo; @@ -953,9 +924,10 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr aMtf.Stop(); aMtf.WindStart(); - const Size aExtSize( aOut->PixelToLogic( Size( 0, 0 ) ) ); - Size aBoundSize( aBound.GetWidth() + ( aExtSize.Width() ), - aBound.GetHeight() + ( aExtSize.Height() ) ); + // tdf#126319 Immediately add needed size to target's PrefSize + const Size aBoundSize( + basegfx::fround(aBound.getWidth() + aHalfPixelInMtf.getWidth()), + basegfx::fround(aBound.getHeight() + aHalfPixelInMtf.getHeight())); aMtf.SetPrefMapMode( aMap ); aMtf.SetPrefSize( aBoundSize ); @@ -963,7 +935,7 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr if( !bVectorType ) { Size aOutSize; - aGraphic = GetBitmapFromMetaFile( aMtf, true, CalcSize( rSettings.mnWidth, rSettings.mnHeight, aBoundSize, aOutSize ) ); + aGraphic = GetBitmapFromMetaFile( aMtf, CalcSize( rSettings.mnWidth, rSettings.mnHeight, aBoundSize, aOutSize ) ); } else { diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 105798f51446..5aba0452296e 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -1277,8 +1277,7 @@ void GDIMetaFile::Rotate( Degree10 nAngle10 ) static void ImplActionBounds( tools::Rectangle& o_rOutBounds, const tools::Rectangle& i_rInBounds, - const std::vector<tools::Rectangle>& i_rClipStack, - tools::Rectangle* o_pHairline ) + const std::vector<tools::Rectangle>& i_rClipStack ) { tools::Rectangle aBounds( i_rInBounds ); if( ! i_rInBounds.IsEmpty() && ! i_rClipStack.empty() && ! i_rClipStack.back().IsEmpty() ) @@ -1290,17 +1289,9 @@ static void ImplActionBounds( tools::Rectangle& o_rOutBounds, o_rOutBounds.Union( aBounds ); else o_rOutBounds = aBounds; - - if(o_pHairline) - { - if( ! o_pHairline->IsEmpty() ) - o_pHairline->Union( aBounds ); - else - *o_pHairline = aBounds; - } } -tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::Rectangle* pHairline ) const +tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference ) const { ScopedVclPtrInstance< VirtualDevice > aMapVDev( i_rReference ); @@ -1311,17 +1302,12 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R std::vector<vcl::PushFlags> aPushFlagStack; tools::Rectangle aBound; - - if(pHairline) - *pHairline = tools::Rectangle(); - const sal_uLong nCount(GetActionSize()); for(sal_uLong a(0); a < nCount; a++) { MetaAction* pAction = GetAction(a); const MetaActionType nActionType = pAction->GetType(); - tools::Rectangle* pUseHairline = (pHairline && aMapVDev->IsLineColor()) ? pHairline : nullptr; switch( nActionType ) { @@ -1331,7 +1317,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R ImplActionBounds( aBound, tools::Rectangle( OutputDevice::LogicToLogic( pAct->GetPoint(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aMapVDev->PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ), - aClipStack, pUseHairline ); + aClipStack ); } break; @@ -1341,7 +1327,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R ImplActionBounds( aBound, tools::Rectangle( OutputDevice::LogicToLogic( pAct->GetPoint(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aMapVDev->PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ), - aClipStack, pUseHairline ); + aClipStack ); } break; @@ -1352,36 +1338,28 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R tools::Rectangle aRect( aP1, aP2 ); aRect.Justify(); - if(pUseHairline) - { - const LineInfo& rLineInfo = pAct->GetLineInfo(); - - if(0 != rLineInfo.GetWidth()) - pUseHairline = nullptr; - } - - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; case MetaActionType::RECT: { MetaRectAction* pAct = static_cast<MetaRectAction*>(pAction); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; case MetaActionType::ROUNDRECT: { MetaRoundRectAction* pAct = static_cast<MetaRoundRectAction*>(pAction); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; case MetaActionType::ELLIPSE: { MetaEllipseAction* pAct = static_cast<MetaEllipseAction*>(pAction); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1390,7 +1368,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R MetaArcAction* pAct = static_cast<MetaArcAction*>(pAction); // FIXME: this is imprecise // e.g. for small arcs the whole rectangle is WAY too large - ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1399,7 +1377,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R MetaPieAction* pAct = static_cast<MetaPieAction*>(pAction); // FIXME: this is imprecise // e.g. for small arcs the whole rectangle is WAY too large - ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1408,7 +1386,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R MetaChordAction* pAct = static_cast<MetaChordAction*>(pAction); // FIXME: this is imprecise // e.g. for small arcs the whole rectangle is WAY too large - ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1417,15 +1395,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R MetaPolyLineAction* pAct = static_cast<MetaPolyLineAction*>(pAction); tools::Rectangle aRect( pAct->GetPolygon().GetBoundRect() ); - if(pUseHairline) - { - const LineInfo& rLineInfo = pAct->GetLineInfo(); - - if(0 != rLineInfo.GetWidth()) - pUseHairline = nullptr; - } - - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1433,7 +1403,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaPolygonAction* pAct = static_cast<MetaPolygonAction*>(pAction); tools::Rectangle aRect( pAct->GetPolygon().GetBoundRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1441,7 +1411,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaPolyPolygonAction* pAct = static_cast<MetaPolyPolygonAction*>(pAction); tools::Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1453,7 +1423,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R aMapVDev->GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen() ); Point aPt( pAct->GetPoint() ); aRect.Move( aPt.X(), aPt.Y() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1466,7 +1436,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R 0, pAct->GetDXArray() ); Point aPt( pAct->GetPoint() ); aRect.Move( aPt.X(), aPt.Y() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1479,7 +1449,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R pAct->GetWidth() ); Point aPt( pAct->GetPoint() ); aRect.Move( aPt.X(), aPt.Y() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1495,7 +1465,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R Point aPt( pAct->GetStartPoint() ); aRect.Move( aPt.X(), aPt.Y() ); aRect.SetRight( aRect.Left() + pAct->GetWidth() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1503,7 +1473,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaBmpScaleAction* pAct = static_cast<MetaBmpScaleAction*>(pAction); tools::Rectangle aRect( pAct->GetPoint(), pAct->GetSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1511,7 +1481,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaBmpScalePartAction* pAct = static_cast<MetaBmpScalePartAction*>(pAction); tools::Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1519,7 +1489,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaBmpExScaleAction* pAct = static_cast<MetaBmpExScaleAction*>(pAction); tools::Rectangle aRect( pAct->GetPoint(), pAct->GetSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1527,7 +1497,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaBmpExScalePartAction* pAct = static_cast<MetaBmpExScalePartAction*>(pAction); tools::Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1535,7 +1505,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaGradientAction* pAct = static_cast<MetaGradientAction*>(pAction); tools::Rectangle aRect( pAct->GetRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1543,7 +1513,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaGradientExAction* pAct = static_cast<MetaGradientExAction*>(pAction); tools::Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1557,7 +1527,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaHatchAction* pAct = static_cast<MetaHatchAction*>(pAction); tools::Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1565,7 +1535,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaTransparentAction* pAct = static_cast<MetaTransparentAction*>(pAction); tools::Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1575,7 +1545,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R // MetaFloatTransparentAction is defined limiting its content Metafile // to its geometry definition(Point, Size), so use these directly const tools::Rectangle aRect( pAct->GetPoint(), pAct->GetSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1583,7 +1553,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaEPSAction* pAct = static_cast<MetaEPSAction*>(pAction); tools::Rectangle aRect( pAct->GetPoint(), pAct->GetSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1623,7 +1593,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaBmpAction* pAct = static_cast<MetaBmpAction*>(pAction); tools::Rectangle aRect( pAct->GetPoint(), aMapVDev->PixelToLogic( pAct->GetBitmap().GetSizePixel() ) ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1631,7 +1601,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaBmpExAction* pAct = static_cast<MetaBmpExAction*>(pAction); tools::Rectangle aRect( pAct->GetPoint(), aMapVDev->PixelToLogic( pAct->GetBitmapEx().GetSizePixel() ) ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1639,7 +1609,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaMaskAction* pAct = static_cast<MetaMaskAction*>(pAction); tools::Rectangle aRect( pAct->GetPoint(), aMapVDev->PixelToLogic( pAct->GetBitmap().GetSizePixel() ) ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1647,7 +1617,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaMaskScalePartAction* pAct = static_cast<MetaMaskScalePartAction*>(pAction); tools::Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1655,7 +1625,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaMaskScalePartAction* pAct = static_cast<MetaMaskScalePartAction*>(pAction); tools::Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1663,7 +1633,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaWallpaperAction* pAct = static_cast<MetaWallpaperAction*>(pAction); tools::Rectangle aRect( pAct->GetRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; @@ -1671,7 +1641,7 @@ tools::Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, tools::R { MetaTextRectAction* pAct = static_cast<MetaTextRectAction*>(pAction); tools::Rectangle aRect( pAct->GetRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack ); } break; diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 7fd24f419a95..37e13abc57a3 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -591,23 +591,16 @@ Bitmap ImpGraphic::getBitmap(const GraphicConversionParameters& rParameters) con if(GraphicType::GdiMetafile == getType()) { - // get hairline and full bound rect - tools::Rectangle aHairlineRect; - const tools::Rectangle aRect(maMetaFile.GetBoundRect(*aVDev, &aHairlineRect)); - - if(!aRect.IsEmpty() && !aHairlineRect.IsEmpty()) - { - // expand if needed to allow bottom and right hairlines to be added - if(aRect.Right() == aHairlineRect.Right()) - { - aPixelSize.setWidth(aPixelSize.getWidth() + 1); - } - - if(aRect.Bottom() == aHairlineRect.Bottom()) - { - aPixelSize.setHeight(aPixelSize.getHeight() + 1); - } - } + // tdf#126319 Removed correction based on hairline-at-the-extremes of + // the metafile. The task shows that this is no longer sufficient since + // less hairlines get used in general - what is good, but breaks that + // old fix. Anyways, hairlines are a left-over from non-AA times + // when it was not possible to paint lines taller than one pixel. + // This might need to be corrected further using primitives and + // the possibility to get better-quality ranges for correction. For + // now, always add that one pixel. + aPixelSize.setWidth(aPixelSize.getWidth() + 1); + aPixelSize.setHeight(aPixelSize.getHeight() + 1); } if(aVDev->SetOutputSizePixel(aPixelSize)) |