Prerequisites
Description
When using the DrawImage method to draw an image outside of the original image's bounds (i.e., where the two images do not overlap), an ImageProcessingException is thrown, with message Cannot draw image because the source image does not overlap the target image.. I would have expected the method to silently do nothing, instead.
Steps to Reproduce
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
Image smallerImage = Image.Load(@"C:\Users\Giorgio\Downloads\test50x50.jpg"); // A 50x50 pixel image
Image image = new Image<SixLabors.ImageSharp.PixelFormats.Rgba32>(100, 100); // A new 100x100 image on which to draw.
// These work:
image.Mutate(x => x.DrawImage(smallerImage, new Point(10, 10), new GraphicsOptions()));
image.Mutate(x => x.DrawImage(smallerImage, new Point(-20, -20), new GraphicsOptions()));
image.Mutate(x => x.DrawImage(smallerImage, new Point(80, 80), new GraphicsOptions()));
// These throw the exception:
image.Mutate(x => x.DrawImage(smallerImage, new Point(110, 110), new GraphicsOptions()));
image.Mutate(x => x.DrawImage(smallerImage, new Point(-60, -60), new GraphicsOptions()));
System Configuration
- ImageSharp.Drawing version: tried with 1.0.0-beta14 and 1.0.0-beta14.10
- Other ImageSharp packages and versions: tried with ImageSharp 2.0.0 and 3.0.0-alpha.0.11
- Environment (Operating system, version and so on): Windows 10
- .NET Framework version: .NET 6
- Additional information: N/A
Prerequisites
DEBUGandRELEASEmodeDescription
When using the
DrawImagemethod to draw an image outside of the original image's bounds (i.e., where the two images do not overlap), anImageProcessingExceptionis thrown, with messageCannot draw image because the source image does not overlap the target image.. I would have expected the method to silently do nothing, instead.Steps to Reproduce
System Configuration