-
-
Notifications
You must be signed in to change notification settings - Fork 888
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
Other ImageSharp packages and versions
SixLabors.ImageSharp.Drawing 2.0.1
Environment (Operating system, version and so on)
Win10 22H2
.NET Framework version
7
Description
After upgrading the ImageSharp nuget package today, several of my unit tests started failing. They are all related to overlaying images that hang over the bottom edge of the bottom image.
The exception being thrown is:
System.AggregateException: One or more errors occurred. (Specified argument was out of the range of valid values. (Parameter 'DangerousGetRowSpan(100). Y was out of range. Height=100')) ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'DangerousGetRowSpan(100). Y was out of range. Height=100')
It only seems to happen when a Y value is larger than the height of the bottom image.
I'm just getting started with ImageSharp and have been impressed by the amount of thought and hard work that has been put into the library. Thank you, and hopefully I provided everything we need here.
Steps to Reproduce
Test method to reproduce the exception:
public void TestOverlayImageOffEdge()
{
using var bottom = new Image<Rgb24>(100, 100, Color.Black);
using var top = new Image<Rgb24>(100, 100, Color.White);
// OK (expected)
bottom.Mutate(i => i.DrawImage(top, new Point(0, 0), 1f));
// OK (expected, overhangs X direction by 1 pixel)
bottom.Mutate(i => i.DrawImage(top, new Point(1, 0), 1f));
// throws System.AggregateException
bottom.Mutate(i => i.DrawImage(top, new Point(0, 1), 1f));
}I had a quick look at the source code and wondered if providing a source rectangle would help -- it did. The below line appears to be a workaround.
// OK
bottom.Mutate(i => i.DrawImage(top, new Point(0, 1), new Rectangle(0, 0, 100, 99), 1f));Images
No response