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

Popular posts from this blog

Tutorial: Using Google Cloud Storage from C# and .NET

Late 2008 Macbook only giving 1.5 gb/s speed with 6 gb/s Intel SSD?

The ridiculous interview experience