Lines with an applied DashStyle are wrongly drawn <p>Doing some GIS programming I stumbled over the following strange issue: When I apply a transformation matrix with fairly large transformation values to a Graphics object and then draw a line from point A to point B, it is drawn crooked as soon as I apply a DashStyle to the used Pen object.</p> <p>Here is some sample code:</p> <pre><code>protected override void OnPaint( PaintEventArgs e ) { base.OnPaint( e ); Graphics g = e.Graphics; g.Clear( Color.White ); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; Matrix m = new System.Drawing.Drawing2D.Matrix(); m.Reset(); m.Translate( -1520106.88f, -6597594.5f, MatrixOrder.Append ); m.Scale( 0.393068463f, -0.393068463f, MatrixOrder.Append ); g.Transform = m; g.TranslateTransform( 0, 400 ); Pen p1 = new Pen( Color.Green, 8.0f ); Pen p2 = new Pen( Color.Magenta, 7.0f ); PointF[] roadLine = new PointF[2]; roadLine[0] = new PointF( 1520170.13f, 6596633.0f ); roadLine[1] = new PointF( 1521997.38f, 6596959.0f ); // Normal (solid line) g.DrawLines( p1, roadLine ); g.DrawLines( p2, roadLine ); g.TranslateTransform( 0, -200 ); //Dashed g.DrawLines( p1, roadLine ); p2.DashStyle = DashStyle.Dash; g.DrawLines( p2, roadLine ); g.TranslateTransform( 0, -200 ); //Dashed g.DrawLines( p1, roadLine ); p2.DashStyle = DashStyle.DashDot; g.DrawLines( p2, roadLine ); g.TranslateTransform( 0, -200 ); //Dash-Dot-Dot g.DrawLines( p1, roadLine ); p2.DashStyle = DashStyle.DashDotDot; g.DrawLines( p2, roadLine ); } </code></pre> <p>If you put this in a new Windows Forms app and run it, you'll see some solid lines and some dashed lines (with different dash styles). I would expect the dashed lines would completely overlay the respective solid line, but they don't.</p> <p>Note that both the green, solid lines and the dashed lines use the coordinates for point A and point B.</p> <p>Is this expected behaviour, or should I report this as a .NET bug?</p> <p>I tested with Visual Studio 2008 and .NET 2.0 and .NET 3.5.</p>