Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ protected override void OnFrameApply(ImageFrame<TPixelBg> source)
top = 0;
}

// clamp the height/width to the availible space left to prevent overflowing
foregroundRectangle.Width = Math.Min(source.Width - left, foregroundRectangle.Width);
foregroundRectangle.Height = Math.Min(source.Height - top, foregroundRectangle.Height);

int width = foregroundRectangle.Width;
int height = foregroundRectangle.Height;
if (width <= 0 || height <= 0)
Expand Down
21 changes: 21 additions & 0 deletions tests/ImageSharp.Tests/Drawing/DrawImageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,25 @@ public void Issue2608_NegOffset<TPixel>(TestImageProvider<TPixel> provider)
appendPixelTypeToFileName: false,
appendSourceFileOrDescription: false);
}

[Theory]
[WithFile(TestImages.Png.Issue2447, PixelTypes.Rgba32)]
public void Issue2603<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> foreground = provider.GetImage();
using Image<Rgba32> background = new(100, 100, new Rgba32(0, 255, 255));

background.Mutate(c => c.DrawImage(foreground, new Point(80, 80), new Rectangle(32, 32, 32, 32), 1F));

background.DebugSave(
provider,
appendPixelTypeToFileName: false,
appendSourceFileOrDescription: false);

background.CompareToReferenceOutput(
provider,
appendPixelTypeToFileName: false,
appendSourceFileOrDescription: false);
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.