-
-
Notifications
You must be signed in to change notification settings - Fork 888
Closed
Labels
Description
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
DEBUGandRELEASEmode - I have searched open and closed issues to ensure it has not already been reported
ImageSharp version
3.1.4
Other ImageSharp packages and versions
ImageSharp.Drawing 2.1.3
Environment (Operating system, version and so on)
Ubuntu 22.04, AMD Ryzen 9 7950X
.NET Framework version
8.0
Description
When using the rotation through the AffineTransformBuilder the result is not the same as the .Rotate() there seems to be 1 pixel offset.
Here the sample code of what I would expect
using (var img = new Image<Rgba32>(100, 100, Color.DimGray))
{
img.Mutate(c => c
.Rotate(180)
.Fill(Color.Aqua, new RectangleF(49, 49, 2, 2))
);
img.Save("rotation-rotate.png");
}Steps to Reproduce
When I do the same with the .Transform() I'm getting this:
using (var img = new Image<Rgb24>(100, 100, Color.DimGray))
{
img.Mutate(c => c
.Transform(new AffineTransformBuilder().AppendRotationDegrees(180))
.Fill(Color.Aqua, new RectangleF(49, 49, 2, 2))
);
img.Save("rotation-center.png");
}Another example with non centered rotation
for (int i = 0; i <= 10; i++)
{
using (var img = new Image<Rgba32>(100, 100, Color.DimGray))
{
img.Mutate(c => c
.Transform(new AffineTransformBuilder().AppendTranslation(new Vector2(100, 100)))
.Transform(new AffineTransformBuilder().AppendRotationDegrees(i * 18, new Vector2(100, 100)))
.Fill(Color.Aqua, new RectangleF(99, 99, 2, 2))
);
img.Save($"rotation-{i}.png");
}
}The rotation seems to be centered 1 pixel too much toward the bottom-right
Images
No response
christianrondeau




