Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6915457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:28:39+00:00 2026-05-27T09:28:39+00:00

Doing some GIS programming I stumbled over the following strange issue: When I apply

  • 0

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.

Here is some sample 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 );
}

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.

Note that both the green, solid lines and the dashed lines use the coordinates for point A and point B.

Is this expected behaviour, or should I report this as a .NET bug?

I tested with Visual Studio 2008 and .NET 2.0 and .NET 3.5.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:28:40+00:00Added an answer on May 27, 2026 at 9:28 am

    Yes, it’s a bug. Should you report it? I don’t think Microsoft is going to do anything about it.

    You can try changing your graphics routine to try and not work on such a scale or just avoid using the DashStyle property. Setting your own DashPattern doesn’t solve the problem either.

    I think WPF would handle this situation better, since it’s vector based, not pixel based.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In doing some reworking of my web application I encountered the following issue: Although
While doing some JavaScript performance tests I came up with the following piece of
Doing some code reading and stumbled upon this snippet that I haven't seen before:
In doing some work on a project I stumbled across a formatting situation on
After doing some joins and stuff I have table in the following format name
While doing some R&D I found a code using the following statement Uri uri
In doing some database work I ran across a strange problem. I'm trying to
Doing some css, so threw this quick fiddle together to show the issue I
Was doing some benchmarking with IsNumeric today and compared it to the following function:
Doing some jquery animation. I have certain divs set up with an attribute of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.