Skip to content

Rasterizing artifacts when rendering line with DrawLines #15

@FrancoFun

Description

@FrancoFun

Description

When plotting a graph using DrawLines, if the curve crosses the same y coordinate multiple times, some unwanted horizontal lines are being rendered.

Steps to Reproduce

Here's code producing the issue displayed in the image below. Artifacts are particularly visible on the bottom right corner.

public static void DrawLinesTest()
{
    int width = 1000;
    int height = 500;
    using (var image = new Image<Rgba32>(width, height))
    {
        image.Mutate(imageContext =>
        {
            imageContext.BackgroundColor(Rgba32.White);
            int pointCount = 1234;
            var line = Enumerable.Range(0, pointCount).Select(x => x * width / (float)pointCount).Select(x => new PointF(x, (0.5f + (float)Math.Sin(x / 3) / 2) * height)).ToArray();
            imageContext.DrawLines(new Rgba32(255, 0, 0), 1, line);
        });

        using (var file = File.Create("DrawLinesTest.png"))
        {
            image.SaveAsPng(file);
        }
    }
}

drawlinetest

System Configuration

  • ImageSharp version: 1.0.0-beta0002
  • Other ImageSharp packages and versions: Drawing version 1.0.0-beta0002
  • Environment (Operating system, version and so on): VS2017, Windows 10
  • .NET Framework version: .net Core 2.0 console application
  • Additional information: Saving the image as bmp didn't change anything

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions