Skip to content

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

@JimBobSquarePants

Description

@JimBobSquarePants

Discussed in #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<Bgra32> bitmap = new Image<Bgra32>(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

Metadata

Metadata

Assignees

No one assigned

    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