Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void resizeImage(string imgPath, string newPath, int Height)
- {
- FileStream fs = new FileStream(imgPath, FileMode.Open, FileAccess.Read);
- Image imgToResize = Image.FromStream(fs);
- fs.Close();
- int sourceWidth = imgToResize.Width;
- int sourceHeight = imgToResize.Height;
- float nPercent = 0;
- float newWidth;
- nPercent = ((float)Height / (float)sourceHeight);
- newWidth = ((float)sourceWidth * nPercent);
- Bitmap b = new Bitmap((int)newWidth, Height);
- Graphics g = Graphics.FromImage((Image)b);
- g.InterpolationMode = InterpolationMode.HighQualityBicubic;
- g.DrawImage(imgToResize, 0, 0, newWidth, Height);
- g.Dispose();
- imgToResize.Save(newPath);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement