使用WPF绘图时,如何摆脱这些“尖峰”视觉瑕疵? [英] How can I get rid of these 'spike' visual artifacts when drawing with WPF?

查看:76
本文介绍了使用WPF绘图时,如何摆脱这些“尖峰”视觉瑕疵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在为地图绘制应用程序绘制一些图块(小正方形图像)。

I'm current drawing some tile (small square images) for a mapping app.

我正在使用WPF在这些图块上绘制形状。

I'm using WPF to draw shapes on to these tiles.

我有一个构成所绘制多边形的地理空间坐标列表。

I have a list of geospatial coordinates that make up polygons that are drawn.

构成这些多边形的地理空间坐标多边形将转换为像素坐标。

The geospatial coordinates that make up these polygons are converted in to pixel coordinates.

在各种设置的细节级别创建图块。

The tiles are created at various set levels of detail.

在这些细节级别中的大多数都可以绘制。但是在某些级别上,视觉伪像以尖峰或线条的形式出现。

At most of these levels of detail the drawing is fine; but at certain levels a visual artifact appears in the form of a spike or a line.

在此示例中,这些图像的细节级别分为三个不同级别,

Here's an example, these images are at three different levels of detail, one which shows the problem and two either side where the problem isn't occurring.

此图像是最高详细级别,并且可以:

This image is the highest detail level and is ok:

此图像位于中等细节级别,并且显示峰值(沿85号公路最容易发现):

This image is at the medium detail level and exhibists the spikes (The one along road 85 is easiest to spot):

此图像处于最低细节级别,并且可以:

This image is at the lowest detail level and is ok:

在多边形中的两条线彼此靠近和/或形成一个密集点(收敛)时,就会出现尖峰。

The spikes appear to occur when two lines in the polygon get close to each other and/or form a dense point (convergence).

我们已经检查了源数据这些文物不会t存在(它在大多数时间都能正确渲染的事实也得到了证实。)

We have checked the source data and these artifacts don't exist (this is also confirmed by the fact it renders correctly most of the time).

下一个可疑对象是坐标转换过程,但我们再次对其进行了检查,

The next suspect was the coordinate conversion process, but again we checked it and the points being produced shouldn't be drawn in this way.

这使WPF成为罪魁祸首,使我们陷入困境,因为我们无法简单地解决任何问题

That leaves WPF as the culprit which leaves us in a hard place as we can't simply fix whatever the issue is as we could with our own code.

你们以前见过这种东西吗?

Have you guys seen this kinda thing before?

一个修复程序太棒了;)

A fix would be fantastic ;)

目前看来,我们要么不得不忍受这个问题,要么转而使用Direct2D。我们已经放弃了GDI +渲染,因为它是一个进程中的单线程。

At the moment it's looking like we either have to put up with this issue or switch to using Direct2D. We already moved away from GDI+ rendering due to it being single threaded within a process.

推荐答案

解决方案是更改LineJoin属性

The solution is to change the LineJoin property on the Pen object to 'Round'.

http://msdn.microsoft.com/en-us/library/system.windows.media.pen.linejoin.aspx

http:// msdn.microsoft.com/en-us/library/system.windows.media.penlinejoin.aspx

非常感谢Moozhe在评论。

Many thanks to Moozhe who provided this answer in the comments.

这篇关于使用WPF绘图时,如何摆脱这些“尖峰”视觉瑕疵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆