Skip to content

X or Y negative-positive-negative causes ArgumentOutOfRangeException in Draw(). #170

@ControlDesign

Description

@ControlDesign

Negative, then positive, then negative X or Y causes DrawPathExtensions.Draw to throw ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'edgeIdx').

To recreate use my 3 points and invoke Draw() as follows:

                    points = new List<PointF>(new PointF[] {
                        new PointF(170.92926f, 0f),
                        new PointF(166.381f, 4.548294f),
                        new PointF(180.50574f, 4.548294f),
                        new PointF(175.7349f, 9.319138f),
                        new PointF(147.33237f, 0f),
                        new PointF(137.5681f, -9.764252f),
                        new PointF(118.26215f, 0f),
                        new PointF(113.71387f, 4.548294f),
                        new PointF(175.76965f, 0f),
                        new PointF(132.60944f, -43.160202f)});

                    //Distill it down a little bit.
                    //Negative Y, then positive, then negative throws exception
                    points = new List<PointF>(new PointF[] {
                        //new PointF(170.92926f, 0f),
                        //new PointF(166.381f, 4.548294f),
                        //new PointF(180.50574f, 4.548294f),
                        //new PointF(175.7349f, 9.319138f),
                        //new PointF(147.33237f, 0f),
                        new PointF(110f, -10f),
                        new PointF(120f, 20f),
                        //new PointF(113.71387f, 4.548294f),
                        //new PointF(175.76965f, 45.01f),
                        new PointF(130f, -30f)
                        });

                    IPath open_simple_path = new PathBuilder().AddLines(points.ToArray()).Build();

                    //SixLabors.ImageSharp.Drawing.Processing.DrawPathExtensions.Draw(
                    //imageContext, Color.AliceBlue, grbx.pathc_global_skeleton[bone].Item2 * f_scale_fac, pathc_local2);
                    try
                    {
                        if (points.Count() >= 2 && bool_non_negative)
                            SixLabors.ImageSharp.Drawing.Processing.DrawPathExtensions.Draw(
                        imageContext, Color.AliceBlue, 3, open_simple_path);
                    } catch (Exception e2)
                    {
                        rtb1.Clear();
                        rtb1.Font = new System.Drawing.Font("Consolas", 10f);
                        rtb1.AppendText(e2.Message + "\n");
                        
                        //autocode the point array that caused the exception
                        rtb1.AppendText($"points = new List<PointF>(new PointF[] {{\n");                                
                        for (int i = 0; i < points.Count(); i++)
                        {
                            rtb1.AppendText($"new PointF({points[i].X}f, {points[i].Y}f)");
                            if (i < points.Count() - 1)
                                rtb1.AppendText(",\n");
                        }
                        rtb1.AppendText($"\n}});\n");
                    }
  • ImageSharp.Drawing version: beta13
  • Other ImageSharp packages and versions:
  • Environment (Operating system, version and so on): win10 19043.1288
  • .NET Framework version: .NET 6.0
  • Additional information:
    My application is a gerber language parser and writer for circuit board design tools. I have mouse centered zooming on circuit board layers. Initially, I render circuit traces as a skeleton with pen width, and the traces go all over the place. There's a similar bug in Fill(), but I work around it by doing a null clip before and after clipping to an image rectangle to ensure no negative values in the path before invoking Fill(). Now I'm in a dark alley using these open paths rather than closed paths that can be clipped.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions