diff --git a/ImageSharp.Drawing.sln b/ImageSharp.Drawing.sln index ffc24ef8..575d4a5e 100644 --- a/ImageSharp.Drawing.sln +++ b/ImageSharp.Drawing.sln @@ -28,7 +28,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISSUE_TEMPLATE", "ISSUE_TEMPLATE", "{FBE8C1AD-5AEC-4514-9B64-091D8E145865}" ProjectSection(SolutionItems) = preProject .github\ISSUE_TEMPLATE\config.yml = .github\ISSUE_TEMPLATE\config.yml - .github\ISSUE_TEMPLATE\oss-bug-report.md = .github\ISSUE_TEMPLATE\oss-bug-report.md + .github\ISSUE_TEMPLATE\oss-bug-report.yml = .github\ISSUE_TEMPLATE\oss-bug-report.yml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{815C0625-CD3D-440F-9F80-2D83856AB7AE}" diff --git a/src/ImageSharp.Drawing/Processing/RecolorBrush.cs b/src/ImageSharp.Drawing/Processing/RecolorBrush.cs index 797e88d6..95738114 100644 --- a/src/ImageSharp.Drawing/Processing/RecolorBrush.cs +++ b/src/ImageSharp.Drawing/Processing/RecolorBrush.cs @@ -136,8 +136,15 @@ public RecolorBrushApplicator( /// public override void Apply(Span scanline, int x, int y) { - Span amounts = this.blenderBuffers.AmountSpan.Slice(0, scanline.Length); - Span overlays = this.blenderBuffers.OverlaySpan.Slice(0, scanline.Length); + if (x < 0 || y < 0 || x >= this.Target.Width || y >= this.Target.Height) + { + return; + } + + // Limit the scanline to the bounds of the image relative to x. + scanline = scanline[..Math.Min(this.Target.Width - x, scanline.Length)]; + Span amounts = this.blenderBuffers.AmountSpan[..scanline.Length]; + Span overlays = this.blenderBuffers.OverlaySpan[..scanline.Length]; for (int i = 0; i < scanline.Length; i++) {