Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageProcessingException when using DrawImage to draw an image outside of the original image's bounds #2406

Closed
4 tasks done
arklumpus opened this issue Jun 1, 2022 · 1 comment
Labels

Comments

@arklumpus
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp.Drawing
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants