From 04e3ada20004656fc63e8d08d214881279e82928 Mon Sep 17 00:00:00 2001 From: perploug Date: Sat, 15 Feb 2014 16:42:20 +0100 Subject: [PATCH] Fixes small calculation issue in percentage-based cropping Former-commit-id: b7a2e54fe5657a86237ac83b2dcc033f90426037 --- src/ImageProcessor/Processors/Crop.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ImageProcessor/Processors/Crop.cs b/src/ImageProcessor/Processors/Crop.cs index 344f13f86..7662158d0 100644 --- a/src/ImageProcessor/Processors/Crop.cs +++ b/src/ImageProcessor/Processors/Crop.cs @@ -159,12 +159,11 @@ namespace ImageProcessor.Processors // Work out the percentages. float left = cropLayer.Left * sourceWidth; float top = cropLayer.Top * sourceWidth; - float right = sourceWidth - (cropLayer.Right * sourceWidth); - float bottom = sourceHeight - (cropLayer.Bottom * sourceHeight); - //float right = (sourceWidth - (cropLayer.Right * sourceWidth)) - left; - //float bottom = (sourceHeight - (cropLayer.Bottom * sourceHeight)) - top; + + float width = (1 - cropLayer.Left - cropLayer.Right) * sourceWidth; + float height = (1 - cropLayer.Top - cropLayer.Bottom) * sourceHeight; - rectangleF = new RectangleF(left, top, right, bottom); + rectangleF = new RectangleF(left, top, width, height); } else {