Crop

RasterImage.Crop method (1 of 2)

Crops the specified rectangle.

public virtual void Crop(Rectangle rectangle)
Parameter Type Description
rectangle Rectangle The rectangle.

Examples

The following code example shows how to crop an image and save it.

[C#]

// Implement correct Crop method for PSD files.
string sourceFileName = "1.psd";
string exportPathPsd = "CropTest.psd";
string exportPathPng = "CropTest.png";
using (RasterImage image = Image.Load(sourceFileName) as RasterImage)
{
    image.Crop(new Rectangle(10, 30, 100, 100));
    image.Save(exportPathPsd, new PsdOptions());
    image.Save(exportPathPng, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}

See Also


RasterImage.Crop method (2 of 2)

Crop image with shifts.

public virtual void Crop(int leftShift, int rightShift, int topShift, int bottomShift)
Parameter Type Description
leftShift Int32 The left shift.
rightShift Int32 The right shift.
topShift Int32 The top shift.
bottomShift Int32 The bottom shift.

See Also