From ce6a80c398931ca38e5e154cc238dede98e78845 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 23 May 2016 23:31:02 +1000 Subject: [PATCH] Fix Entropy Crop Former-commit-id: bef320055b03844132eeaad17397791b95baa087 Former-commit-id: 8f2a8bfdcbe4b328635449b668880e26ecbfa635 Former-commit-id: 7a1afac9bb3bf9d85fb3d4f84bf00b6dc20491d4 --- .../Samplers/EntropyCrop.cs | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/ImageProcessorCore/Samplers/EntropyCrop.cs b/src/ImageProcessorCore/Samplers/EntropyCrop.cs index 32f3b384b2..05332123ee 100644 --- a/src/ImageProcessorCore/Samplers/EntropyCrop.cs +++ b/src/ImageProcessorCore/Samplers/EntropyCrop.cs @@ -69,26 +69,21 @@ namespace ImageProcessorCore.Samplers } int targetY = this.cropRectangle.Y; - int startX = targetRectangle.X; - int targetX = this.cropRectangle.X; - int endX = this.cropRectangle.Width; - int maxX = this.cropRectangle.Right - 1; - int maxY = this.cropRectangle.Bottom - 1; + int targetBottom = this.cropRectangle.Bottom; + int startX = this.cropRectangle.X; + int endX = this.cropRectangle.Right; Parallel.For( startY, endY, y => { - for (int x = startX; x < endX; x++) + if (y >= targetY && y < targetBottom) { - int offsetY = y + targetY; - offsetY = offsetY.Clamp(0, maxY); - - int offsetX = x + targetX; - offsetX = offsetX.Clamp(0, maxX); - - target[x, y] = source[offsetX, offsetY]; + for (int x = startX; x < endX; x++) + { + target[x - startX, y - targetY] = source[x, y]; + } } this.OnRowProcessed();