//
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
//
namespace ImageSharp
{
using System;
using Processing.Processors;
///
/// Extension methods for the type.
///
public static partial class ImageExtensions
{
///
/// Crops an image to the given width and height.
///
/// The pixel format.
/// The image to resize.
/// The target image width.
/// The target image height.
/// The
public static Image Crop(this Image source, int width, int height)
where TColor : struct, IPackedPixel, IEquatable
{
return Crop(source, new Rectangle(0, 0, width, height));
}
///
/// Crops an image to the given rectangle.
///
/// The pixel format.
/// The image to crop.
///
/// The structure that specifies the portion of the image object to retain.
///
/// The
public static Image Crop(this Image source, Rectangle cropRectangle)
where TColor : struct, IPackedPixel, IEquatable
{
CropProcessor processor = new CropProcessor(cropRectangle);
source.ApplyProcessor(processor, source.Bounds);
return source;
}
}
}