RasterImage.Crop

Crop(Rectangle)

Crops the specified rectangle.

public virtual void Crop(Rectangle rectangle)
ParameterTypeDescription
rectangleRectangleThe 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


Crop(int, int, int, int)

Crop image with shifts.

public virtual void Crop(int leftShift, int rightShift, int topShift, int bottomShift)
ParameterTypeDescription
leftShiftInt32The left shift.
rightShiftInt32The right shift.
topShiftInt32The top shift.
bottomShiftInt32The bottom shift.

See Also