Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Bad rendering of PathGeometry?

$
0
0

Hello all. I'm using an Adorner class to draw paths on top of an image displayed in an Image control. I have a series of Point objects that define the path. I'm getting strange rendering in some cases and I'm having trouble pinning down what the cause is. In one case I have two points defined by the coordinates (83,206) and (82,206). I add them to my path figure as follows in my Adorner class:

// Assume "points" contains the two Point objects.

PathFigure pathFigure = new PathFigure();
pathFigure.StartPoint = points[0];

for(Int32 x = 1; x < points.Length; x++)
{
    LineSegment lineSegment = new LineSegment();
    lineSegment.Point = new Point(points[x].X, points[x].Y);
    pathFigure.Segments.Add(lineSegment);
}

pathFigure.IsClosed = true;

PathGeometry pathGeometry = new PathGeometry();
pathGeometry.Figures.Add(pathFigure);

// Render:
drawingContext.DrawGeometry(null, new Pen(Brushes.Red, 1.5), pathGeometry);

When this is rendered to the screen, what should be a very short line instead appears as a line about 8 pxels long that badly overshoots the pixel pair. In other cases, longer paths render properly except at certain locations where the rendered line again appears to overshoot the coordinates by a large margin, sometimes going entirely off of the image control. What on earth is going on here?

Edit: I'm including a screenshot below; the original and the original with the path geometry drawn via the adorner (in red). I'm tracing around the perimeter of white regions using the above method with the geometry defined by an array of Point objects. Everything looks very nice most of the time. The two Point coordinates I discuss above are near the middle of the screen...you can see the line that was drawn looks very strange. These "overshoots" are cropping up elsewhere in the image as well. I've confirmed that my Point arrays contain the proper points, it seems to be how the rendering engine is drawing the closed path. Has anyone seen this before?


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>