Browse Source

Resize pad now respects anchor mode.

Former-commit-id: a579d27a41aceb1421fce03a760df0dee1dbe0e3
Former-commit-id: 451175a87f191d6d1034846baf82690bf7d33030
pull/17/head
James South 11 years ago
parent
commit
a9cfa103d3
  1. 28
      src/ImageProcessor/Imaging/Resizer.cs
  2. 7
      src/TestWebsites/MVC/Views/Home/Index.cshtml

28
src/ImageProcessor/Imaging/Resizer.cs

@ -152,14 +152,38 @@ namespace ImageProcessor.Imaging
if (percentHeight < percentWidth)
{
ratio = percentHeight;
destinationX = Convert.ToInt32((width - (sourceWidth * ratio)) / 2);
destinationWidth = Convert.ToInt32(sourceWidth * percentHeight);
switch (anchorPosition)
{
case AnchorPosition.Left:
destinationX = 0;
break;
case AnchorPosition.Right:
destinationX = (int)(width - (sourceWidth * ratio));
break;
default:
destinationX = Convert.ToInt32((width - (sourceWidth * ratio)) / 2);
break;
}
}
else
{
ratio = percentWidth;
destinationY = Convert.ToInt32((height - (sourceHeight * ratio)) / 2);
destinationHeight = Convert.ToInt32(sourceHeight * percentWidth);
switch (anchorPosition)
{
case AnchorPosition.Top:
destinationY = 0;
break;
case AnchorPosition.Bottom:
destinationY = (int)(height - (sourceHeight * ratio));
break;
default:
destinationY = (int)((height - (sourceHeight * ratio)) / 2);
break;
}
}
}

7
src/TestWebsites/MVC/Views/Home/Index.cshtml

@ -25,18 +25,15 @@
</div>*@
</div>
</section>
@*<section>
<section>
<div class="row">
<h2>Reside Pad</h2>
<div class="col-s-4">
<img src="/images/format-Penguins.jpg?width=300&height=500" />
</div>
<div class="col-s-8">
<img src="/images/udendørs.jpg?width=600&height=250" />
</div>
</div>
</section>
<section>
@*<section>
<div class="row">
<h2>Resize Crop</h2>
<div class="col-s-4">

Loading…
Cancel
Save