New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rasterizing artifacts when rendering line with DrawLines #496

Closed
FrancoFun opened this Issue Mar 22, 2018 · 9 comments

Comments

6 participants
@FrancoFun
Copy link

FrancoFun commented Mar 22, 2018

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
@zati-

This comment has been minimized.

Copy link

zati- commented May 15, 2018

Same problem here, workaround is to disable antialiasing

@antonfirsov

This comment has been minimized.

Copy link
Member

antonfirsov commented May 15, 2018

Might be related to (or actually the same issue as) #572 and SixLabors/Shapes/#42.

@tocsoft is my supposition right?

@tocsoft

This comment has been minimized.

Copy link
Member

tocsoft commented May 15, 2018

yeah, looks like its going to be the exact same root issues.

@JimBobSquarePants JimBobSquarePants added this to To Do in ImageSharp.Drawing via automation May 16, 2018

@antonfirsov antonfirsov added this to the 1.0.0-beta4 milestone May 20, 2018

@woutware

This comment has been minimized.

Copy link
Contributor

woutware commented May 22, 2018

This is indeed a duplicate of #572.

I've verified it now works ok after the fix, see attached image.

drawlinestest

@JimBobSquarePants

This comment has been minimized.

Copy link
Member

JimBobSquarePants commented May 23, 2018

Closing now as in nightlies

ImageSharp.Drawing automation moved this from To Do to Done May 23, 2018

@antonfirsov antonfirsov reopened this May 23, 2018

ImageSharp.Drawing automation moved this from Done to In progress May 23, 2018

@antonfirsov

This comment has been minimized.

Copy link
Member

antonfirsov commented May 23, 2018

Shouldn't be fixed yet. SL.ImageSharp.Drawing is still referencing shapes 1.0.0-ci0018.

We still need a PR updating shapes.

@JimBobSquarePants

This comment has been minimized.

Copy link
Member

JimBobSquarePants commented May 23, 2018

I thought the PR was in no?

@antonfirsov

This comment has been minimized.

Copy link
Member

antonfirsov commented May 23, 2018

@JimBobSquarePants only in SL.Shapes: SixLabors/Shapes#43

We need to update the reference to have these issues closed.

@antonfirsov

This comment has been minimized.

Copy link
Member

antonfirsov commented May 26, 2018

Fixed with #596 in beta4.

ImageSharp.Drawing automation moved this from In progress to Done May 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment