How can I get rid of these “splashes” of visual artifacts when drawing with WPF?

I am currently drawing some fragments (small square images) for a matching application.

I use WPF to draw shapes on these fragments.

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

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

Tiles are created at different levels of detail.

At most of these levels of detail, the drawing is good; but at certain levels the visual artifact appears as a spike or line.

In this example, these images are presented at three different levels of detail: one of them shows the problem and two sides where the problem does not arise.

This image is the highest level of detail and in order:

Ok image

This image is at a medium level of detail and shows spikes (one on track 85 is easiest to spot):

Bad image

This image is at the lowest level of detail and in order:

enter image description here

Adhesions appear when two lines in a polygon approach each other and / or form a dense point (convergence).

We checked the source data, and these artifacts do not exist (this is also confirmed by the fact that it does the right thing most of the time).

The next suspect was the coordinate transformation process, but we checked it again, and the created points should not be drawn in this way.

This leaves WPF the culprit, which leaves us in a difficult position, since we cannot just fix everything that was in our own codes.

Have you seen this before?

The fix would be fantastic;)

At the moment, it looks like we either have to come to terms with this problem, or switch to using Direct2D. We have already moved away from GDI + rendering due to the fact that it was a single thread within a process.

+4
source share
1 answer

The solution is to change the LineJoin property of 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

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

0
source

Source: https://habr.com/ru/post/1436839/


All Articles