diff --git a/src/ImageSharp/Image/PixelAccessor{TPixel}.cs b/src/ImageSharp/Image/PixelAccessor{TPixel}.cs index fca57b3c8..50e65a082 100644 --- a/src/ImageSharp/Image/PixelAccessor{TPixel}.cs +++ b/src/ImageSharp/Image/PixelAccessor{TPixel}.cs @@ -52,10 +52,11 @@ namespace SixLabors.ImageSharp /// /// Initializes a new instance of the class. /// + /// The to use for buffer allocations. /// The width of the image represented by the pixel buffer. /// The height of the image represented by the pixel buffer. - public PixelAccessor(int width, int height) - : this(width, height, Configuration.Default.MemoryManager.Allocate2D(width, height, true), true) + public PixelAccessor(MemoryManager memoryManager, int width, int height) + : this(width, height, memoryManager.Allocate2D(width, height, true), true) { } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs index b85432ac5..2e2f5e3a6 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs @@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Processing.Processors int maxY = endY - 1; int maxX = endX - 1; - using (var targetPixels = new PixelAccessor(source.Width, source.Height)) + using (var targetPixels = new PixelAccessor(configuration.MemoryManager, source.Width, source.Height)) { source.CopyTo(targetPixels); diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs index 362fa5c50..e79a6cf27 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs @@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.Processing.Processors int height = source.Height; ParallelOptions parallelOptions = configuration.ParallelOptions; - using (var firstPassPixels = new PixelAccessor(width, height)) + using (var firstPassPixels = new PixelAccessor(configuration.MemoryManager, width, height)) using (PixelAccessor sourcePixels = source.Lock()) { this.ApplyConvolution(firstPassPixels, sourcePixels, source.Bounds(), this.KernelX, parallelOptions); diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs index c0d3fdcfe..da64a970e 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Processing.Processors int maxY = endY - 1; int maxX = endX - 1; - using (var targetPixels = new PixelAccessor(source.Width, source.Height)) + using (var targetPixels = new PixelAccessor(configuration.MemoryManager, source.Width, source.Height)) { source.CopyTo(targetPixels); diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs index b22a49798..af2c29759 100644 --- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs @@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Processing.Processors int radius = this.BrushSize >> 1; int levels = this.Levels; - using (var targetPixels = new PixelAccessor(source.Width, source.Height)) + using (var targetPixels = new PixelAccessor(configuration.MemoryManager, source.Width, source.Height)) { source.CopyTo(targetPixels); diff --git a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs index 2657daaa8..556874586 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Processing.Processors int minX = Math.Max(this.CropRectangle.X, sourceRectangle.X); int maxX = Math.Min(this.CropRectangle.Right, sourceRectangle.Right); - using (var targetPixels = new PixelAccessor(this.CropRectangle.Width, this.CropRectangle.Height)) + using (var targetPixels = new PixelAccessor(configuration.MemoryManager, this.CropRectangle.Width, this.CropRectangle.Height)) { Parallel.For( minY, diff --git a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs index de60177f2..f52bc97c1 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Processing.Processors int height = source.Height; int halfHeight = (int)Math.Ceiling(source.Height * .5F); - using (var targetPixels = new PixelAccessor(width, height)) + using (var targetPixels = new PixelAccessor(configuration.MemoryManager, width, height)) { Parallel.For( 0, @@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.Processing.Processors int height = source.Height; int halfWidth = (int)Math.Ceiling(width * .5F); - using (var targetPixels = new PixelAccessor(width, height)) + using (var targetPixels = new PixelAccessor(configuration.MemoryManager, width, height)) { Parallel.For( 0, diff --git a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs index 86a0c7360..ddacf219b 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs @@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Processing.Processors Matrix3x2 matrix = this.GetCenteredMatrix(source, this.processMatrix); Rectangle sourceBounds = source.Bounds(); - using (var targetPixels = new PixelAccessor(width, height)) + using (var targetPixels = new PixelAccessor(configuration.MemoryManager, width, height)) { Parallel.For( 0, @@ -159,7 +159,7 @@ namespace SixLabors.ImageSharp.Processing.Processors int width = source.Width; int height = source.Height; - using (var targetPixels = new PixelAccessor(height, width)) + using (var targetPixels = new PixelAccessor(configuration.MemoryManager, height, width)) { using (PixelAccessor sourcePixels = source.Lock()) { @@ -193,7 +193,7 @@ namespace SixLabors.ImageSharp.Processing.Processors int width = source.Width; int height = source.Height; - using (var targetPixels = new PixelAccessor(width, height)) + using (var targetPixels = new PixelAccessor(configuration.MemoryManager, width, height)) { Parallel.For( 0, @@ -224,7 +224,7 @@ namespace SixLabors.ImageSharp.Processing.Processors int width = source.Width; int height = source.Height; - using (var targetPixels = new PixelAccessor(height, width)) + using (var targetPixels = new PixelAccessor(configuration.MemoryManager, height, width)) { Parallel.For( 0, diff --git a/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs index 316e2a2af..9f6f1d17d 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs @@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.Processing.Processors Matrix3x2 matrix = this.GetCenteredMatrix(source, this.processMatrix); Rectangle sourceBounds = source.Bounds(); - using (var targetPixels = new PixelAccessor(width, height)) + using (var targetPixels = new PixelAccessor(configuration.MemoryManager, width, height)) { Parallel.For( 0, diff --git a/src/ImageSharp/Quantizers/Quantize.cs b/src/ImageSharp/Quantizers/Quantize.cs index 296f4192d..11494a867 100644 --- a/src/ImageSharp/Quantizers/Quantize.cs +++ b/src/ImageSharp/Quantizers/Quantize.cs @@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp QuantizedImage quantized = quantizer.Quantize(img.Frames.RootFrame, maxColors); int palleteCount = quantized.Palette.Length - 1; - using (var pixels = new PixelAccessor(quantized.Width, quantized.Height)) + using (var pixels = new PixelAccessor(source.GetMemoryManager(), quantized.Width, quantized.Height)) { Parallel.For( 0,