How to crop an image in c#
This works:
using (Image FullsizeImage = Image.FromFile(sourceFilePath)) { using (Bitmap NewImage = new Bitmap(FullsizeImage.Width, ThumbHeight)) { using (Graphics newgraphics = Graphics.FromImage(NewImage)) { newgraphics.DrawImage(FullsizeImage, 0, 0, new Rectangle(0, 0, FullsizeImage.Width, ThumbHeight), GraphicsUnit.Pixel); newgraphics.Flush(); } NewImage.Save(outFilePath, ImageFormat.Png); } }
Comments
Post a Comment