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

OutOfMemory exception if element is bigger than page #9

Open
AqueM opened this issue Jan 14, 2021 · 1 comment
Open

OutOfMemory exception if element is bigger than page #9

AqueM opened this issue Jan 14, 2021 · 1 comment

Comments

@AqueM
Copy link

AqueM commented Jan 14, 2021

var croppedImage = new Rectangle(pixelRatio * element.Location.X, pixelRatio * element.Location.Y, pixelRatio * element.Size.Width, pixelRatio * element.Size.Height); screenshot = screenshot.Clone(croppedImage, screenshot.PixelFormat);

This line will throw a critical exception if the element overflows page, because it is attempting to crop more (element size) than the size of the bitmap (page size). See: https://stackoverflow.com/questions/199468/c-sharp-image-clone-out-of-memory-exception
It might be beneficial to restrict the max size of the crop to bitmap size to avoid this.

@LarsThunberg
Copy link

Yes, I have learned to live with this issue...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants