Skip to content

Commit a8ef280

Browse files
committed
处理空白内容
1 parent 8f70cd9 commit a8ef280

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

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

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

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public bool TryRender([NotNullWhen(true)] out SKBitmap? skBitmap)
142142
var skBitmap = new SKBitmap(renderWidth, renderHeight, SKColorType.Bgra8888, SKAlphaType.Premul);
143143

144144
SKCanvas canvas = new SKCanvas(skBitmap);
145-
canvas.Translate(offsetX, offsetY);
145+
//canvas.Translate(offsetX, offsetY);
146146
canvas.Scale(scaleX, scaleY);
147147

148148
return (skBitmap, canvas);
@@ -268,6 +268,50 @@ private static bool RenderRecord(SKCanvas canvas, WmfRenderStatus renderStatus,
268268

269269
canvas.DrawPath(skPath, renderStatus.Paint);
270270
}
271+
// + [16] {== WmfPolyPolygonRecord ==
272+
// RecordSize: 5717 words = 11434 bytes
273+
// RecordType: 0x0538 (RecordType.META_POLYPOLYGON)
274+
// NumberOfPolygons: 5
275+
// PointsPerPolygon:
276+
// 2497
277+
// 17
278+
// 17
279+
// 161
280+
// 162
281+
// Points:
282+
// 7949, 13486
283+
// 7817, 13485
284+
// 7677, 13485
285+
// ...
286+
else if (wmfDocumentRecord is WmfPolyPolygonRecord polyPolygonRecord)
287+
{
288+
// The META_POLYPOLYGON Record paints a series of closed polygons. Each polygon is outlined by using the pen and filled by using the brush and polygon fill mode; these are defined in the playback device context. The polygons drawn by this function can overlap.
289+
290+
if (polyPolygonRecord.Points.Count < polyPolygonRecord.GetPointsCount())
291+
{
292+
return false;
293+
}
294+
295+
var currentPointIndex = 0;
296+
using var skPath = new SKPath();
297+
foreach (var pointCount in polyPolygonRecord.PointsPerPolygon)
298+
{
299+
skPath.Reset();
300+
var skPointArray = polyPolygonRecord.Points
301+
.Skip(currentPointIndex)
302+
.Take(pointCount)
303+
.Select(t => t.ToSKPoint())
304+
.ToArray();
305+
skPath.AddPoly(skPointArray);
306+
307+
renderStatus.UpdateSkiaFillStatus();
308+
canvas.DrawPath(skPath, renderStatus.Paint);
309+
renderStatus.UpdateSkiaStrokeStatus();
310+
canvas.DrawPath(skPath, renderStatus.Paint);
311+
312+
currentPointIndex += pointCount;
313+
}
314+
}
271315

272316
// 文本
273317
// - [13] {== WmfSetTextColorRecord ==

0 commit comments

Comments
 (0)