SixLabors / ImageSharp

:camera: A modern, cross-platform, 2D Graphics library for .NET
https://sixlabors.com/products/imagesharp/
Other
7.34k stars 847 forks source link

Handle case when Foreground image overhangs bottom of background image during DrawImage Call (3.1 target) #2610

Closed tocsoft closed 9 months ago

tocsoft commented 9 months ago

Prerequisites

Description

Prevents the ArgumentOutOfRangeException when the area of interest of the foreground image will be drawn past the edge of the bounds of the background image.

fixes #2603 related to #2609

Targeting 3.1 release branch

JimBobSquarePants commented 9 months ago

Thanks for fixing this.

We'll need to PR this against release/v3.1.x here also as well as update the ImageBrush to allow negative offsetting since it does the same thing.

tocsoft commented 9 months ago

đź‘Ť i'll rebaseline the PRs against the 3.1 branch this weekend.

Regarding ImageBrush I was just looking over the code and I don't see how that would effected by these issues at all, this one is about the final blending stage and that's handled differently over there, and the other doesn't makes sense for textures either... I'm fairly sure that these changes should only effect the explicit DrawImage api.

JimBobSquarePants commented 9 months ago

Thanks, appreciate it. See here for what I mean with the ImageBrush. It does the same reset of the position when given negative location. That’s why I exposed the rectangle constructor.

https://github.com/SixLabors/ImageSharp.Drawing/discussions/305

tocsoft commented 9 months ago

managed to reduce it to a single pair of clamping operations to solve the ArgumentOutOfRange exception.