- static Bitmap CropImage(Image orgImg, Rectangle sRect, Rectangle destRect)
- {
- if (destRect == null)
- {
- destRect = new Rectangle(Point.Empty, sRect.Size);
- }
- var cropImage = new Bitmap(destRect.Value.Width, destRect.Value.Height);
- using(var graphics = Graphics.FromImage(cropImage))
- {
- graphics.DrawImage(orgImg, destRect.Value, sRect, GraphicsUnit.Pixel);
- }
- return cropImage;
- }
The .Net Framework contains a lot of methods and overloads that you can use to manipulate images.