From 96370a7901db609d31fe784e557a5a75c0541d46 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 8 Jul 2016 16:32:10 +1000 Subject: [PATCH] No need to store the firstpass image as a variable. Former-commit-id: a1f0b1c9a76b4bf24a704cfd95a922b11ded8189 Former-commit-id: df58b4f394a68e48fd3755ce250ec4ec062cc62f Former-commit-id: 9234222f848afbdf9461e16ea76974fe56da37a6 --- .../Samplers/Processors/ResizeProcessor.cs | 10 ++-------- tests/ImageProcessorCore.Benchmarks/Samplers/Resize.cs | 8 ++++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs index 95ead2bf0..fcb7d0d5c 100644 --- a/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs +++ b/src/ImageProcessorCore/Samplers/Processors/ResizeProcessor.cs @@ -13,11 +13,6 @@ namespace ImageProcessorCore.Processors /// public class ResizeProcessor : ImageSampler { - /// - /// The image used for storing the first pass pixels. - /// - private Image firstPass; - /// /// Initializes a new instance of the class. /// @@ -54,8 +49,6 @@ namespace ImageProcessorCore.Processors this.HorizontalWeights = this.PrecomputeWeights(targetRectangle.Width, sourceRectangle.Width); this.VerticalWeights = this.PrecomputeWeights(targetRectangle.Height, sourceRectangle.Height); } - - this.firstPass = new Image(target.Width, source.Height); } /// @@ -121,8 +114,9 @@ namespace ImageProcessorCore.Processors // A 2-pass 1D algorithm appears to be faster than splitting a 1-pass 2D algorithm // First process the columns. Since we are not using multiple threads startY and endY // are the upper and lower bounds of the source rectangle. + Image firstPass = new Image(target.Width, source.Height); using (PixelAccessor sourcePixels = source.Lock()) - using (PixelAccessor firstPassPixels = this.firstPass.Lock()) + using (PixelAccessor firstPassPixels = firstPass.Lock()) using (PixelAccessor targetPixels = target.Lock()) { Parallel.For( diff --git a/tests/ImageProcessorCore.Benchmarks/Samplers/Resize.cs b/tests/ImageProcessorCore.Benchmarks/Samplers/Resize.cs index 479392cc8..bee3fe3cb 100644 --- a/tests/ImageProcessorCore.Benchmarks/Samplers/Resize.cs +++ b/tests/ImageProcessorCore.Benchmarks/Samplers/Resize.cs @@ -12,9 +12,9 @@ [Benchmark(Baseline = true, Description = "System.Drawing Resize")] public Size ResizeSystemDrawing() { - using (Bitmap source = new Bitmap(400, 400)) + using (Bitmap source = new Bitmap(2000, 2000)) { - using (Bitmap destination = new Bitmap(100, 100)) + using (Bitmap destination = new Bitmap(400, 400)) { using (Graphics graphics = Graphics.FromImage(destination)) { @@ -32,8 +32,8 @@ [Benchmark(Description = "ImageProcessorCore Resize")] public CoreSize ResizeCore() { - CoreImage image = new CoreImage(400, 400); - image.Resize(100, 100); + CoreImage image = new CoreImage(2000, 2000); + image.Resize(400, 400); return new CoreSize(image.Width, image.Height); } }