How to cut a part of image in C#

Check out the Graphics Class on MSDN.

Here's an example that will point you in the right direction (notice the Rectangle object):

public Bitmap CropImage(Bitmap source, Rectangle section)
{
    var bitmap = new Bitmap(section.Width, section.Height);
    using (var g = Graphics.FromImage(bitmap))
    {
        g.DrawImage(source, 0, 0, section, GraphicsUnit.Pixel);
        return bitmap;
    }
}

// Example use:     
Bitmap source = new Bitmap(@"C:\tulips.jpg");
Rectangle section = new Rectangle(new Point(12, 50), new Size(150, 150));

Bitmap CroppedImage = CropImage(source, section);

Another way to corp an image would be to clone the image with specific starting points and size.

int x= 10, y=20, width=200, height=100;
Bitmap source = new Bitmap(@"C:\tulips.jpg");
Bitmap CroppedImage = source.Clone(new System.Drawing.Rectangle(x, y, width, height), source.PixelFormat);

Tags:

C#

.Net

Graphics