Browse Source

Fixing rounding issue

Former-commit-id: a814798f117a0386ac112e31c8dd21bdaee5992e
pull/17/head
James South 12 years ago
parent
commit
b91a9cd6c6
  1. 14
      src/ImageProcessor/Processors/Resize.cs
  2. 1
      src/TestWebsites/NET45/Test_Website_NET45/Images/header_1.jpg.REMOVED.git-id
  3. 5
      src/TestWebsites/NET45/Test_Website_NET45/Test_Website_NET45.csproj
  4. 7
      src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Index.cshtml

14
src/ImageProcessor/Processors/Resize.cs

@ -252,13 +252,13 @@ namespace ImageProcessor.Processors
{
ratio = percentHeight;
destinationX = (int)((width - (sourceWidth * ratio)) / 2);
destinationWidth = (int)Math.Floor(sourceWidth * percentHeight);
destinationWidth = (int)Math.Ceiling(sourceWidth * percentHeight);
}
else
{
ratio = percentWidth;
destinationY = (int)((height - (sourceHeight * ratio)) / 2);
destinationHeight = (int)Math.Floor(sourceHeight * percentWidth);
destinationHeight = (int)Math.Ceiling(sourceHeight * percentWidth);
}
}
@ -285,7 +285,7 @@ namespace ImageProcessor.Processors
break;
}
destinationHeight = (int)Math.Floor(sourceHeight * percentWidth);
destinationHeight = (int)Math.Ceiling(sourceHeight * percentWidth);
}
else
{
@ -304,7 +304,7 @@ namespace ImageProcessor.Processors
break;
}
destinationWidth = (int)Math.Floor(sourceWidth * percentHeight);
destinationWidth = (int)Math.Ceiling(sourceWidth * percentHeight);
}
}
@ -330,13 +330,13 @@ namespace ImageProcessor.Processors
// If height or width is not passed we assume that the standard ratio is to be kept.
if (height == 0)
{
destinationHeight = (int)Math.Floor(sourceHeight * percentWidth);
destinationHeight = (int)Math.Ceiling(sourceHeight * percentWidth);
height = destinationHeight;
}
if (width == 0)
{
destinationWidth = (int)Math.Floor(sourceWidth * percentHeight);
destinationWidth = (int)Math.Ceiling(sourceWidth * percentHeight);
width = destinationWidth;
}
@ -376,7 +376,7 @@ namespace ImageProcessor.Processors
}
// An unwanted border appears when using InterpolationMode.HighQualityBicubic to resize the image
// as the algorithm appears to be pulling averaging detail from surFlooring pixels beyond the edge
// as the algorithm appears to be pulling averaging detail from surCeilinging pixels beyond the edge
// of the image. Using the ImageAttributes class to specify that the pixels beyond are simply mirror
// images of the pixels within solves this problem.
using (ImageAttributes wrapMode = new ImageAttributes())

1
src/TestWebsites/NET45/Test_Website_NET45/Images/header_1.jpg.REMOVED.git-id

@ -0,0 +1 @@
f956fa8105d6d9628a0413b8884ec7684e820381

5
src/TestWebsites/NET45/Test_Website_NET45/Test_Website_NET45.csproj

@ -127,15 +127,16 @@
<Content Include="Images\cmyk.png" />
<Content Include="Images\color-vision-test.gif" />
<Content Include="Images\Desert.jpg" />
<Content Include="Images\emma.jpg" />
<Content Include="Images\fid11246.jpg" />
<Content Include="Images\fid9141.jpg" />
<Content Include="Images\header_1.jpg" />
<Content Include="Images\Hydrangeas.jpg" />
<Content Include="Images\Jellyfish.jpg" />
<Content Include="Images\jrt.jpg" />
<Content Include="Images\Koala.jpg" />
<Content Include="Images\Lighthouse.jpg" />
<Content Include="Images\lomo.jpg" />
<Content Include="Images\MSwanson - Wide Large - Rock 02.jpg" />
<Content Include="Images\negative.png" />
<Content Include="Images\negative2.png" />
<Content Include="Images\Penguins-200.jpg" />
@ -145,10 +146,12 @@
<Content Include="Images\Penguins.jpg" />
<Content Include="Images\Penguins.png" />
<Content Include="Images\Penguins.tif" />
<Content Include="Images\rocks.jpg" />
<Content Include="Images\sample1.jpg" />
<Content Include="Images\srgb.jpg" />
<Content Include="Images\srgb.png" />
<Content Include="Images\text.png" />
<Content Include="Images\thor.jpg" />
<Content Include="Images\Tulips.jpg" />
<Content Include="Images\udendørs-374.jpg" />
<Content Include="Images\udendørs.jpg" />

7
src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Index.cshtml

@ -209,4 +209,11 @@
</div>
</div>
</section>
<section>
<div class="row">
<h2>Rounding</h2>
<img src="/Images/header_1.jpg?crop=0-43-683-200&width=750&height=220" />
<img src="/Images/header_1.jpg?width=750&crop=0-48-750-220" />
</div>
</section>
</article>

Loading…
Cancel
Save