Skip to content

Instantly share code, notes, and snippets.

@cprieto
Created June 11, 2009 17:42
Show Gist options
  • Save cprieto/128103 to your computer and use it in GitHub Desktop.
Save cprieto/128103 to your computer and use it in GitHub Desktop.
public static Image ToSize(this Image image, int width, int height)
{
var resizedImage = new Bitmap(width, height);
using (var graphics = Graphics.FromImage(resizedImage))
{
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.DrawImage(image, 0, 0, width, height);
}
return resizedImage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment