diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-02-01 21:03:39 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-02-02 09:04:56 +0100 |
commit | ddc0714c40c6ea85336431a88b523f3e5c63a3f8 (patch) | |
tree | 9611f9733643b0d14868187a7e4bfd9f11c8a956 /vcl/source | |
parent | 945fb5d8693478559e489d2c4cf948adf6033fe1 (diff) |
tdf#139869 vcl: fix lazy-loading of BMP images with logic size
Regression from commit 7b355669c6ddeab2e6cec692d6afdff41c61d0fb
(Function to load graphic swapped out (loaded on demand), 2018-04-14),
the code assumes that the map mode and size of a graphic is the same
when the image is not yet loaded and when it's loaded already.
This was not the case for the BMP import, where ImplReadDIBBody()
produced a map mode with scaling and MapUnit::MapMM as the map unit,
while GraphicDescriptor assumed that the logic size is always MapUnit::Map100thMM.
This resulted in SwNoTextNode::HasContour() using one map mode when the
contour polygon is imported and an other one was used while renderin,
effectively hiding the image.
Fix the problem by extending GraphicDescriptor, so a format detector can
opt in to provide its own map mode and size according to that map mode,
this way the detector and the BMP import will create matching map modes
and sizes, resulting in a visible image in the bugdoc.
Change-Id: I71e786a4601c63f58da2e6ab9d7681ec6dd7b806
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110275
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/filter/graphicfilter2.cxx | 17 | ||||
-rw-r--r-- | vcl/source/gdi/impgraph.cxx | 7 |
2 files changed, 23 insertions, 1 deletions
diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index a40e54002cff..2b66d2d29395 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -156,13 +156,21 @@ bool GraphicDescriptor::ImpDetectBMP( SvStream& rStm, bool bExtendedInfo ) // logical width rStm.SeekRel( 4 ); rStm.ReadUInt32( nTemp32 ); + sal_uInt32 nXPelsPerMeter = 0; if ( nTemp32 ) + { aLogSize.setWidth( ( aPixSize.Width() * 100000 ) / nTemp32 ); + nXPelsPerMeter = nTemp32; + } // logical height rStm.ReadUInt32( nTemp32 ); + sal_uInt32 nYPelsPerMeter = 0; if ( nTemp32 ) + { aLogSize.setHeight( ( aPixSize.Height() * 100000 ) / nTemp32 ); + nYPelsPerMeter = nTemp32; + } // further validation, check for rational values if ( ( nBitsPerPixel > 24 ) || ( nCompression > 3 ) ) @@ -170,6 +178,15 @@ bool GraphicDescriptor::ImpDetectBMP( SvStream& rStm, bool bExtendedInfo ) nFormat = GraphicFileFormat::NOT; bRet = false; } + + if (bRet && nXPelsPerMeter && nYPelsPerMeter) + { + maPreferredMapMode + = MapMode(MapUnit::MapMM, Point(), Fraction(1000, nXPelsPerMeter), + Fraction(1000, nYPelsPerMeter)); + + maPreferredLogSize = Size(aPixSize.getWidth(), aPixSize.getHeight()); + } } } rStm.Seek( nStmPos ); diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 6d10f7268e38..e16e12b0ef5b 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -397,7 +397,12 @@ void ImpGraphic::setPrepared(bool bAnimated, const Size* pSizeHint) // conversion will work with the output device DPI, not the graphic // DPI. Size aLogSize = aDescriptor.GetSize_100TH_MM(); - if (aLogSize.getWidth() && aLogSize.getHeight()) + if (aDescriptor.GetPreferredLogSize() && aDescriptor.GetPreferredMapMode()) + { + maSwapInfo.maPrefSize = *aDescriptor.GetPreferredLogSize(); + maSwapInfo.maPrefMapMode = *aDescriptor.GetPreferredMapMode(); + } + else if (aLogSize.getWidth() && aLogSize.getHeight()) { maSwapInfo.maPrefSize = aLogSize; maSwapInfo.maPrefMapMode = MapMode(MapUnit::Map100thMM); |