Created
October 13, 2011 20:50
-
-
Save briandonahue/1285485 to your computer and use it in GitHub Desktop.
Image Resizing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bitmap targetBitmap = new Bitmap(sourceImage, imageSize); | |
Bitmap canvas = new Bitmap(imageSize.Width, imageSize.Height); | |
// Set appropriate resolution | |
targetBitmap.SetResolution(72F, 72F); | |
Graphics g = Graphics.FromImage(canvas); | |
// Makes resized image have a higher quality | |
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; | |
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; | |
// Draw image to new size and resolution | |
g.DrawImage(targetBitmap, 0, 0, imageSize.Width, imageSize.Height); | |
targetBitmap.Save(destinationImagePath, ImageFormat.Jpeg); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment