How to enable anti-aliasing for a polyline drawn with WPF StreamGeometry?
I need to draw a polyline into a DrawingVisual. I'm using StreamGeometry for performance reasons. The problem I have is that I can't figure out how to enable anti-aliasing. I can't find any method or property on StreamGeometry or on DrawingContext for anti-aliasing control.
The code below is in IronPython, but it shouldn't matter:
geometry = StreamGeometry()
context = geometry.Open()
context.BeginFigure(Point(10, 10), False, False)
context.LineTo(Point(100, 100), True, False)
context.LineTo(Point(200, 300), True, False)
context.Close()
dv = DrawingVisu开发者_高级运维al()
dc = dv.RenderOpen()
dc.DrawGeometry(None, Pen(Brushes.Blue, 1), geometry)
dc.Close()
To disable anti-aliasing you could use RenderOptons class, with the static method SetEdgeMode it's possible to determine how the edges of non-text drawing primitives of your DependencyObject are rendered.
RenderOptions.SetEdgeMode(MyDependencyObject, EdgeMode.Aliased)
Hope this help.
精彩评论