Browse Source

inline percentHeiught and percentWidth as they are used only in one case each

af/merge-core
Peter Amrehn 8 years ago
parent
commit
4955751599
  1. 6
      src/ImageSharp/Processing/ResizeHelper.cs

6
src/ImageSharp/Processing/ResizeHelper.cs

@ -333,10 +333,6 @@ namespace SixLabors.ImageSharp.Processing
return (new Size(sourceWidth, sourceWidth), new Rectangle(0, 0, sourceWidth, sourceHeight));
}
// Fractional variants for preserving aspect ratio.
float percentHeight = MathF.Abs(height / (float)sourceHeight);
float percentWidth = MathF.Abs(width / (float)sourceWidth);
// Find the shortest distance to go.
int widthDiff = sourceWidth - width;
int heightDiff = sourceHeight - height;
@ -360,12 +356,14 @@ namespace SixLabors.ImageSharp.Processing
if (height > width)
{
destinationWidth = width;
float percentWidth = MathF.Abs(width / (float)sourceWidth);
destinationHeight = (int)MathF.Round(sourceHeight * percentWidth);
height = destinationHeight;
}
else
{
destinationHeight = height;
float percentHeight = MathF.Abs(height / (float)sourceHeight);
destinationWidth = (int)MathF.Round(sourceWidth * percentHeight);
width = destinationWidth;
}

Loading…
Cancel
Save