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

Image.Clone(Configuration) should use the passed Configuration's MemoryAllocator #1642

Open
4 tasks done
antonfirsov opened this issue May 28, 2021 · 0 comments
Open
4 tasks done

Comments

@antonfirsov
Copy link
Member

@antonfirsov antonfirsov commented May 28, 2021

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • 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

Discovered while thinking about the test in #1641.

image.Clone(Configuration) will call the following method eventually:

internal ImageFrame(Configuration configuration, ImageFrame<TPixel> source)
: base(configuration, source.Width, source.Height, source.Metadata.DeepClone())
{
Guard.NotNull(configuration, nameof(configuration));
Guard.NotNull(source, nameof(source));
this.PixelBuffer = this.GetConfiguration().MemoryAllocator.Allocate2D<TPixel>(source.PixelBuffer.Width, source.PixelBuffer.Height);
source.PixelBuffer.FastMemoryGroup.CopyTo(this.PixelBuffer.FastMemoryGroup);
}

We should use the passed configuration's memory allocator instead of this.GetConfiguration().MemoryAllocator. Not a critical user scenario, so triaging to future.

PS:
Would have raised a PR by editing the .cs right away on GitHub, but my OCD doesn't let me to do it without also adding a test :)

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

Successfully merging a pull request may close this issue.

1 participant