public void EnumerateMetafile(Stream emf, float unitSize, PointF destination, DrawLineDelegate drawLine, FillPolygonDelegate fillPolygon) { _transform = new SVG.Gaps.Matrix(); _drawLine = drawLine; _fillPolygon = fillPolygon; _zero = destination; _lineBuffer = new LineBuffer(unitSize); _objects = new Dictionary <uint, ObjectHandle>(); _brush = null; using (var reader = new EmfTools.EmfReader(emf)) { while (!reader.IsEndOfFile) { if (reader.Read() is EmfTools.EmfUnknownRecord record) { Enumerate(record); } } } CommitLine(); }
public void EnumerateMetafile(Stream emf, float unitSize, PointF destination, DrawLineDelegate drawLine, FillPolygonDelegate fillPolygon) { this.Transform = new Matrix(); this._drawLine = drawLine; this._fillPolygon = fillPolygon; this._zero = destination; this._lineBuffer = new MetafileParser.LineBuffer(unitSize); this._objects = new Dictionary <uint, MetafileParser.ObjectHandle>(); this._brush = null; using (EmfReader emfReader = new EmfReader(emf)) { while (!emfReader.IsEndOfFile) { EmfUnknownRecord emfUnknownRecord = emfReader.Read() as EmfUnknownRecord; if (emfUnknownRecord != null) { EmfPlusRecordType recordType = emfUnknownRecord.RecordType; if (recordType <= EmfPlusRecordType.EmfSetPolyFillMode) { if (recordType != EmfPlusRecordType.EmfHeader && recordType != EmfPlusRecordType.EmfEof && recordType != EmfPlusRecordType.EmfSetPolyFillMode) { goto IL_1FE; } } else { switch (recordType) { case EmfPlusRecordType.EmfMoveToEx: this.ProcessMoveToEx(emfUnknownRecord.Data); break; case EmfPlusRecordType.EmfSetMetaRgn: case EmfPlusRecordType.EmfExcludeClipRect: case EmfPlusRecordType.EmfIntersectClipRect: case EmfPlusRecordType.EmfScaleViewportExtEx: case EmfPlusRecordType.EmfScaleWindowExtEx: case EmfPlusRecordType.EmfSetWorldTransform: goto IL_1FE; case EmfPlusRecordType.EmfSaveDC: case EmfPlusRecordType.EmfRestoreDC: case EmfPlusRecordType.EmfCreatePen: case EmfPlusRecordType.EmfDeleteObject: break; case EmfPlusRecordType.EmfModifyWorldTransform: this.ProcessModifyWorldTransform(emfUnknownRecord.Data); break; case EmfPlusRecordType.EmfSelectObject: this.ProcessSelectObject(emfUnknownRecord.Data); break; case EmfPlusRecordType.EmfCreateBrushIndirect: this.ProcessCreateBrushIndirect(emfUnknownRecord.Data); break; default: switch (recordType) { case EmfPlusRecordType.EmfSetMiterLimit: break; case EmfPlusRecordType.EmfBeginPath: this.ProcessBeginPath(emfUnknownRecord.Data); break; case EmfPlusRecordType.EmfEndPath: break; case EmfPlusRecordType.EmfCloseFigure: this.ProcessCloseFigure(emfUnknownRecord.Data); break; case EmfPlusRecordType.EmfFillPath: goto IL_1FE; case EmfPlusRecordType.EmfStrokeAndFillPath: this.ProcessStrokeAndFillPath(emfUnknownRecord.Data); break; default: switch (recordType) { case EmfPlusRecordType.EmfPolygon16: this.ProcessPolygon16(emfUnknownRecord.Data); break; case EmfPlusRecordType.EmfPolyline16: this.ProcessPolyline16(emfUnknownRecord.Data); break; case EmfPlusRecordType.EmfPolyBezierTo16: this.ProcessPolyBezierTo16(emfUnknownRecord.Data); break; case EmfPlusRecordType.EmfPolylineTo16: this.ProcessPolylineTo16(emfUnknownRecord.Data); break; case EmfPlusRecordType.EmfPolyPolyline16: case EmfPlusRecordType.EmfPolyDraw16: case EmfPlusRecordType.EmfCreateMonoBrush: case EmfPlusRecordType.EmfCreateDibPatternBrushPt: case EmfPlusRecordType.EmfPolyTextOutA: case EmfPlusRecordType.EmfPolyTextOutW: goto IL_1FE; case EmfPlusRecordType.EmfPolyPolygon16: this.ProcessPolyPolygon16(emfUnknownRecord.Data); break; case EmfPlusRecordType.EmfExtCreatePen: case EmfPlusRecordType.EmfSetIcmMode: break; default: goto IL_1FE; } break; } break; } } continue; continue; IL_1FE: throw new NotImplementedException(); } } } this.CommitLine(); }
public void EnumerateMetafile(Stream emf, float unitSize, PointF destination, DrawLineDelegate drawLine, FillPolygonDelegate fillPolygon) { Transform = new Matrix(); _drawLine = drawLine; _fillPolygon = fillPolygon; _zero = destination; _lineBuffer = new LineBuffer(unitSize); _objects = new System.Collections.Generic.Dictionary<uint, ObjectHandle>(); _brush = null; using (var reader = new EmfTools.EmfReader(emf)) { while (!reader.IsEndOfFile) { var record = reader.Read() as EmfTools.EmfUnknownRecord; if (record == null) continue; switch (record.RecordType) { case EmfPlusRecordType.EmfHeader: case EmfPlusRecordType.EmfEof: case EmfPlusRecordType.EmfSaveDC: case EmfPlusRecordType.EmfDeleteObject: case EmfPlusRecordType.EmfExtCreatePen: case EmfPlusRecordType.EmfCreatePen: case EmfPlusRecordType.EmfRestoreDC: case EmfPlusRecordType.EmfSetIcmMode: case EmfPlusRecordType.EmfSetMiterLimit: case EmfPlusRecordType.EmfSetPolyFillMode: // Harmless records with no significant side-effects on the shape of the drawn outline break; case EmfPlusRecordType.EmfSelectObject: ProcessSelectObject(record.Data); break; case EmfPlusRecordType.EmfCreateBrushIndirect: ProcessCreateBrushIndirect(record.Data); break; case EmfPlusRecordType.EmfBeginPath: ProcessBeginPath(record.Data); break; case EmfPlusRecordType.EmfEndPath: // TODO: break; case EmfPlusRecordType.EmfStrokeAndFillPath: ProcessStrokeAndFillPath(record.Data); break; case EmfPlusRecordType.EmfMoveToEx: ProcessMoveToEx(record.Data); break; case EmfPlusRecordType.EmfModifyWorldTransform: ProcessModifyWorldTransform(record.Data); break; case EmfPlusRecordType.EmfPolygon16: ProcessPolygon16(record.Data); break; case EmfPlusRecordType.EmfPolyPolygon16: ProcessPolyPolygon16(record.Data); break; case EmfPlusRecordType.EmfPolyline16: ProcessPolyline16(record.Data); break; case EmfPlusRecordType.EmfPolylineTo16: ProcessPolylineTo16(record.Data); break; case EmfPlusRecordType.EmfCloseFigure: ProcessCloseFigure(record.Data); break; case EmfPlusRecordType.EmfPolyBezierTo16: ProcessPolyBezierTo16(record.Data); break; default: throw new NotImplementedException(); } } } CommitLine(); }