Browse Source

Merge remote-tracking branch 'origin/dev'

Former-commit-id: 1e8f95d5996deb5139dfadc72f250ca1f554a5b0
pull/17/head
James South 12 years ago
parent
commit
91ba2b2b84
  1. 49
      src/ImageProcessor/Processors/Resize.cs
  2. 4
      src/ImageProcessor/Properties/AssemblyInfo.cs
  3. 1
      src/Images/Thumbs.db.REMOVED.git-id
  4. BIN
      src/Images/bus.jpg
  5. 1
      src/Nuget/ImageProcessor.1.8.5.0.nupkg.REMOVED.git-id
  6. 3
      src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Index.cshtml
  7. 2
      src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config

49
src/ImageProcessor/Processors/Resize.cs

@ -11,7 +11,6 @@
namespace ImageProcessor.Processors
{
#region Using
using System;
using System.Collections.Generic;
using System.Drawing;
@ -20,10 +19,8 @@ namespace ImageProcessor.Processors
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using ImageProcessor.Extensions;
using ImageProcessor.Imaging;
#endregion
/// <summary>
@ -145,14 +142,14 @@ namespace ImageProcessor.Processors
Size size = this.ParseSize(toParse);
ResizeLayer resizeLayer = new ResizeLayer(size)
{
ResizeMode = this.ParseMode(toParse),
AnchorPosition = this.ParsePosition(toParse),
BackgroundColor = this.ParseColor(toParse),
Upscale = !UpscaleRegex.IsMatch(toParse),
};
resizeLayer.CenterCoordinates = this.ParseCoordinates(toParse);
{
ResizeMode = this.ParseMode(toParse),
AnchorPosition = this.ParsePosition(toParse),
BackgroundColor = this.ParseColor(toParse),
Upscale = !UpscaleRegex.IsMatch(toParse),
CenterCoordinates = this.ParseCoordinates(toParse),
};
this.DynamicParameter = resizeLayer;
return this.SortOrder;
@ -186,7 +183,6 @@ namespace ImageProcessor.Processors
int.TryParse(this.Settings["MaxHeight"], out defaultMaxHeight);
List<Size> restrictedSizes = this.ParseRestrictions(restrictions);
return this.ResizeImage(factory, width, height, defaultMaxWidth, defaultMaxHeight, restrictedSizes, backgroundColor, mode, anchor, upscale, centerCoordinates);
}
#endregion
@ -437,36 +433,25 @@ namespace ImageProcessor.Processors
using (Graphics graphics = Graphics.FromImage(newImage))
{
// We want to use two different blending algorithms for enlargement/shrinking.
// Bicubic is better enlarging for whilst Bilinear is better for shrinking.
// http://www.codinghorror.com/blog/2007/07/better-image-resizing.html
if (image.Width < destinationWidth && image.Height < destinationHeight)
{
// We are making it larger.
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.CompositingQuality = CompositingQuality.HighQuality;
}
else
{
// We are making it smaller.
graphics.SmoothingMode = SmoothingMode.None;
graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.CompositingQuality = CompositingQuality.HighQuality;
}
// An unwanted border appears when using InterpolationMode.HighQualityBicubic to resize the image
// as the algorithm appears to be pulling averaging detail from surrounding 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())
{
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
graphics.Clear(backgroundColor);
Rectangle destRect = new Rectangle(destinationX, destinationY, destinationWidth, destinationHeight);
graphics.DrawImage(image, destRect, 0, 0, sourceWidth, sourceHeight, GraphicsUnit.Pixel, wrapMode);
}
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.Clear(backgroundColor);
Rectangle destRect = new Rectangle(destinationX, destinationY, destinationWidth, destinationHeight);
graphics.DrawImage(image, destRect, 0, 0, sourceWidth, sourceHeight, GraphicsUnit.Pixel);
// Reassign the image.
image.Dispose();
@ -676,4 +661,4 @@ namespace ImageProcessor.Processors
return floats;
}
}
}
}

4
src/ImageProcessor/Properties/AssemblyInfo.cs

@ -32,6 +32,6 @@ using System.Security;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.8.4.0")]
[assembly: AssemblyFileVersion("1.8.4.0")]
[assembly: AssemblyVersion("1.8.5.0")]
[assembly: AssemblyFileVersion("1.8.5.0")]

1
src/Images/Thumbs.db.REMOVED.git-id

@ -1 +0,0 @@
4d0266cc69c162b3cb0ea5d5506c82a525eac00f

BIN
src/Images/bus.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

1
src/Nuget/ImageProcessor.1.8.5.0.nupkg.REMOVED.git-id

@ -0,0 +1 @@
e17abcc95a7db20a8a60f9ca481fbda7b09dd6cc

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

@ -18,7 +18,7 @@
<h3>Cropped Percent</h3>
<img src="/images/Penguins.jpg?width=300&height300&crop=0.1,0.2,0.1,0.6&cropmode=percent" />
<img src="/images/bus.jpg?width=311" />
</div>
</div>
</section>
@ -41,6 +41,7 @@
</div>
<div class="col-s-8">
<img src="/images/udendørs.jpg?width=600&height=250&mode=crop" />
<img src="/images/bus.jpg?width=311&height=250&mode=crop&center=0.2,0.7" />
</div>
</div>
</section>

2
src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config

@ -30,7 +30,7 @@
<settings>
<setting key="MaxWidth" value="3000"/>
<setting key="MaxHeight" value="3000"/>
<setting key="RestrictTo" value="width=300"/>
<!--<setting key="RestrictTo" value="width=300"/>-->
</settings>
</plugin>
<plugin name="Rotate" type="ImageProcessor.Processors.Rotate, ImageProcessor"/>

Loading…
Cancel
Save