SixLabors / ImageSharp.Drawing

:pen: Extensions to ImageSharp containing a cross-platform 2D polygon manipulation API and drawing operations.
https://sixlabors.com/products/imagesharp-drawing/
Other
286 stars 39 forks source link

Bug: DrawLine doesn't draw pixels where line segments overlap. #344

Open JimBobSquarePants opened 1 week ago

JimBobSquarePants commented 1 week ago

Discussed in https://github.com/SixLabors/ImageSharp.Drawing/discussions/339

Originally posted by **woutware** September 3, 2024 Tested with SixLabors.ImageSharp 3.1.5, SixLabors.ImageSharp.Drawing 2.1.4, .NET 6.0: Program to reproduce (Only draws line from (10, 10) to (20, 10). The part where it draws over itself is not drawn): ``` using System; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Drawing.Processing; using SixLabors.Fonts; namespace ConsoleApp { public static class SixLaborsBug { public static void DrawLineBug2() { Image bitmap = new Image(Configuration.Default, 100, 100, new Bgra32(0, 0, 0)); // Only draws line from (10, 10) to (20, 10). The part where it draws over itself is not drawn. bitmap.Mutate( context => { context.DrawLine(Color.Aqua, 1f, new PointF(10, 10), new PointF(90, 10), new PointF(20, 10)); } ); bitmap.Save(@"C:\tmp\DrawLineBug2.png"); } } } ``` Attached is the output bitmap. ![DrawLineBug2](https://github.com/user-attachments/assets/7c8f4fde-c5c4-494d-98fe-35b1cb8829eb)