Skip to content

Fill with a ComplexPolygon change behavior after update from 3.0.0-alpha.0.6 to 3.0.0-alpha.0.7 #378

@Socolin

Description

@Socolin

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

ImageSharp version

4.0

Other ImageSharp packages and versions

3.0.0-alpha.0.7

Environment (Operating system, version and so on)

Ubuntu 24.04

.NET Framework version

net10.0

Description

I'm not sure if this is expected, just want to let you know.

When using a ComplexPolygon in a image.Mutate(x => x.Fill)) after upgrading to 3.0.0-alpha.0.7 it seems that the order of the point in contour of the ComplexPolygon constructor changes the result

As a workaround I can just re-order of the point and it works.

Repro: TestComplexPolygon.zip

Steps to Reproduce

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;

var polygonHole = new ComplexPolygon(
	[
		new PointF(0, 0),
		new PointF(0, 400),
		new PointF(300, 400),
		new PointF(300, 0),
	],
	/*[ By inverting the point order it works
		new PointF(0, 0),
		new PointF(300, 0),
		new PointF(300, 400),
		new PointF(0, 400),
	],*/
	[
		new PointF(150, 100),
		new PointF(50, 300),
		new PointF(250, 300),
	]
);

using var catImage = Image.Load("cat-original.png");
catImage.Mutate(x => x.Resize(300, 400));

using var image = new Image<Rgba32>(300, 400, Color.Transparent.ToPixel<Rgba32>());
image.Mutate(c => c.DrawImage(catImage, new Point(0, 0), new GraphicsOptions()));

image.Mutate(c => c
	.SetGraphicsOptions(new GraphicsOptions
		{
			AlphaCompositionMode = PixelAlphaCompositionMode.DestOut,
		}
	)
	.Fill(Color.Black, polygonHole)
);
image.SaveAsPng("output.png");

Images

Before the update

Image

And after the update I'm getting a transparent image

Image

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