Browse Source

Resize pad now respects anchor mode.

Former-commit-id: f5721fe3086cb7715d2f89d60a2b078fe133050a
Former-commit-id: 713ca5bfb22acbc23ebd432cd97903af368195ee
af/merge-core
James South 11 years ago
parent
commit
9fb7b0ab64
  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