From 798b15958587e394089544ae5f9f0a8f4081062c Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 22 Mar 2016 17:54:38 +1100 Subject: [PATCH] Fix Entropy Crop Former-commit-id: d078a662595f78ac31b27df92fdae70cc5c38731 Former-commit-id: 882d751ab14072058b0e4cfe211c6b602c73b5ce Former-commit-id: cec29371dc77a78d0b55cd52176cebfb896785dc --- src/ImageProcessorCore/Samplers/EntropyCrop.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/ImageProcessorCore/Samplers/EntropyCrop.cs b/src/ImageProcessorCore/Samplers/EntropyCrop.cs index b6fd26915b..928518d53c 100644 --- a/src/ImageProcessorCore/Samplers/EntropyCrop.cs +++ b/src/ImageProcessorCore/Samplers/EntropyCrop.cs @@ -61,9 +61,9 @@ namespace ImageProcessorCore.Samplers /// protected override void Apply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY) { + // Jump out, we'll deal with that later. if (source.Bounds == target.Bounds) { - target.SetPixels(target.Width, target.Height, source.Pixels); return; } @@ -71,9 +71,9 @@ namespace ImageProcessorCore.Samplers int startX = targetRectangle.X; int targetX = this.cropRectangle.X; int endX = this.cropRectangle.Width; - int maxX = endX - 1; + int maxX = this.cropRectangle.Right - 1; int maxY = this.cropRectangle.Bottom - 1; - + Parallel.For( startY, endY, @@ -89,8 +89,19 @@ namespace ImageProcessorCore.Samplers target[x, y] = source[offsetX, offsetY]; } + this.OnRowProcessed(); }); } + + /// + protected override void AfterApply(ImageBase source, ImageBase target, Rectangle targetRectangle, Rectangle sourceRectangle) + { + // Copy the pixels over. + if (source.Bounds == target.Bounds) + { + target.ClonePixels(target.Width, target.Height, source.Pixels); + } + } } }