diff --git a/src/ImageProcessor/Processors/Resize.cs b/src/ImageProcessor/Processors/Resize.cs index 94b0bcef4..d6d34390f 100644 --- a/src/ImageProcessor/Processors/Resize.cs +++ b/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 /// @@ -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 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; } } -} +} \ No newline at end of file diff --git a/src/Images/Thumbs.db.REMOVED.git-id b/src/Images/Thumbs.db.REMOVED.git-id deleted file mode 100644 index 1ed885c06..000000000 --- a/src/Images/Thumbs.db.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -4d0266cc69c162b3cb0ea5d5506c82a525eac00f \ No newline at end of file diff --git a/src/Images/bus.jpg b/src/Images/bus.jpg new file mode 100644 index 000000000..15bbd0c64 --- /dev/null +++ b/src/Images/bus.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:27c958940a4a328791b39ebb89987d35d898670343332d9376e6da748ee99f33 +size 52330