Skip to content

Commit 840c065

Browse files
committed
修复缩放值
1 parent 9be62da commit 840c065

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • Workbench/Wmf/SkiaWmfRenderer/src/SkiaWmfRenderer/Rendering

Workbench/Wmf/SkiaWmfRenderer/src/SkiaWmfRenderer/Rendering/WmfRenderer.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public bool TryRender([NotNullWhen(true)] out SKBitmap? skBitmap)
145145

146146
canvas.Scale(scaleX, scaleY);
147147
//canvas.Translate(offsetX, offsetY);
148+
canvas.Save();
148149

149150
return (skBitmap, canvas);
150151
}
@@ -176,6 +177,19 @@ private static bool RenderRecord(SKCanvas canvas, WmfRenderStatus renderStatus,
176177
// RecordFunction (2 bytes): A 16-bit unsigned integer that defines this WMF record type. The lower byte MUST match the lower byte of the RecordType Enumeration (section 2.1.1.1) table value META_SETBKMODE.
177178
// BkMode (2 bytes): A 16-bit unsigned integer that defines background mix mode. This MUST be one of the values in the MixMode Enumeration (section 2.1.1.20).
178179
}
180+
else if (wmfDocumentRecord is WmfSetWindowExtRecord setWindow)
181+
{
182+
canvas.Restore();
183+
canvas.Save();
184+
185+
if (setWindow.X > 0 && setWindow.Y > 0)
186+
{
187+
var scaleX = renderStatus.Width / (float) setWindow.X;
188+
var scaleY = renderStatus.Height / (float)setWindow.Y;
189+
190+
canvas.Scale(scaleX, scaleY);
191+
}
192+
}
179193
else if (wmfDocumentRecord is WmfSetTextAlignRecord setTextAlignRecord)
180194
{
181195
// RecordFunction (2 bytes): A 16-bit unsigned integer that defines this WMF record type. The lower byte MUST match the lower byte of the RecordType Enumeration (section 2.1.1.1) table value META_SETTEXTALIGN.

0 commit comments

Comments
 (0)