From 69ea4ee8972214974f158aa3a64d44fbdbdacda2 Mon Sep 17 00:00:00 2001 From: "Valeriano A.R" Date: Mon, 9 Feb 2015 19:29:20 +0100 Subject: [PATCH] =?UTF-8?q?Reducci=C3=B3n=20de=20im=C3=A1genes=20de=20alta?= =?UTF-8?q?=20calidad?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ImageCrusher/FrmImageCrusher.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ImageCrusher/FrmImageCrusher.cs b/ImageCrusher/FrmImageCrusher.cs index a55bb51..fefc465 100644 --- a/ImageCrusher/FrmImageCrusher.cs +++ b/ImageCrusher/FrmImageCrusher.cs @@ -8,6 +8,7 @@ using System.Text; using System.Windows.Forms; using System.IO; using System.Drawing.Imaging; +using System.Drawing.Drawing2D; namespace ImageCrusher { @@ -104,7 +105,7 @@ namespace ImageCrusher Directory.CreateDirectory(destPath); } - Image imgThumb = img.GetThumbnailImage(width, height, null, new System.IntPtr()); + Image imgThumb = Image_Resize(img, width, height); string newFileName = String.Format("{0}/{1}.small.jpg", destPath, Path.GetFileNameWithoutExtension(fileName)); imgThumb.Save(newFileName, ImageFormat.Jpeg); @@ -118,5 +119,18 @@ namespace ImageCrusher } lstImagenes_AddLine("End."); } + + + public Image Image_Resize(Image img, int width, int height) + { + Bitmap bitmap = new Bitmap(width, height); + Graphics imgGraph = Graphics.FromImage(bitmap); + imgGraph.CompositingQuality = CompositingQuality.HighQuality; + imgGraph.SmoothingMode = SmoothingMode.HighQuality; + imgGraph.InterpolationMode = InterpolationMode.HighQualityBicubic; + var imgDimesions = new Rectangle(0, 0, width, height); + imgGraph.DrawImage(img, imgDimesions); + return bitmap; + } } }