Reducción de imágenes de alta calidad
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user