diff options
authorMiklos Vajna <>2020-12-09 17:32:06 +0100
committerMiklos Vajna <>2020-12-09 17:32:14 +0100
commit6ca971ca3a4b767fdc75cd2dde022a878dd583a1 (patch)
parentf38c84f1dd1f78763bc72496ff251216bc1209a0 (diff)
vcl: fix logic size of metafile from Graphicdistro/vector/vector-5.4
vector-7.0 has bitmap import filters which set both the preferred size and the preferred pixel size on a BitmapEx. This means that when ImpGraphic::ImplGetGDIMetaFile() gets the bitmap size, it can use maEx.GetPrefSize() directly. Interestingly, the "fall back to pixel size from logic size" logic is still there at other places, e.g. at ImpGraphic::ImplGetPrefSize(). However, on this branch, the bitmap import filters (e.g. PNG import) only sets the preferred pixel size and set the map mode to pixel. This means that directly getting the preferred size results in a zero size, so exporting such a bitmap to WMF/EMF will result in a white rectangle. Fix the problem by using ImplGetPrefSize() (which has the fallback logic) instead of maEx.GetPrefSize() directly -- both for the metafile action and for the preferred size of the metafile. Change-Id: I94090b2e125c0262d4d6d408c8e4d894a0de8872
1 files changed, 6 insertions, 3 deletions
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index b31dbf4828ba..aa7b52cf4c57 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -607,20 +607,23 @@ const GDIMetaFile& ImpGraphic::ImplGetGDIMetaFile() const
pThat->maEx = maSvgData->getReplacement();
+ // Using maEx.GetPrefSize() directly would not fall back from logic size to pixel size.
+ Size aPrefSize = ImplGetPrefSize();
// #123983# directly create a metafile with the same PrefSize and PrefMapMode
// the bitmap has, this will be an always correct metafile
- pThat->maMetaFile.AddAction(new MetaBmpExScaleAction(Point(), maEx.GetPrefSize(), maEx));
+ pThat->maMetaFile.AddAction(new MetaBmpExScaleAction(Point(), aPrefSize, maEx));
- pThat->maMetaFile.AddAction(new MetaBmpScaleAction(Point(), maEx.GetPrefSize(), maEx.GetBitmap()));
+ pThat->maMetaFile.AddAction(new MetaBmpScaleAction(Point(), aPrefSize, maEx.GetBitmap()));
- pThat->maMetaFile.SetPrefSize(maEx.GetPrefSize());
+ pThat->maMetaFile.SetPrefSize(aPrefSize);