static Bitmap RedrawImage(string FileName, int TargetSize) { try { Bitmap newImage; using (Bitmap oldImage = new Bitmap(FileName)) { Size newSize = CalcuateDimentions(oldImage.Size, TargetSize); newImage = new Bitmap(newSize.Width, newSize.Height, PixelFormat.Format24bppRgb); Graphics canvas = Graphics.FromImage(newImage); canvas.SmoothingMode = SmoothingMode.HighQuality; canvas.InterpolationMode = InterpolationMode.HighQualityBicubic; canvas.PixelOffsetMode = PixelOffsetMode.HighQuality; canvas.DrawImage(oldImage, new System.Drawing.Rectangle(new Point(0, 0), newSize)); oldImage.Dispose(); } return newImage; } catch (Exception ex) { throw new Exception("Error attempting to redraw the image", ex); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)