📷 A modern, cross-platform, 2D Graphics library for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

81 lines
2.7 KiB

// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CropLayer.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Encapsulates the properties required to crop an image.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Imaging
{
using System;
/// <summary>
/// Encapsulates the properties required to crop an image.
/// </summary>
public class CropLayer
{
/// <summary>
/// Initializes a new instance of the <see cref="CropLayer"/> class.
/// </summary>
/// <param name="left">
/// The left coordinate of the crop layer.
/// </param>
/// <param name="top">
/// The top coordinate of the crop layer.
/// </param>
/// <param name="right">
/// The right coordinate of the crop layer.
/// </param>
/// <param name="bottom">
/// The bottom coordinate of the crop layer.
/// </param>
/// <param name="cropMode">
/// The <see cref="CropMode"/>.
/// </param>
/// <remarks>
/// If the <see cref="CropMode"/> is set to <value>CropMode.Percentage</value> then the four coordinates
/// become percentages to reduce from each edge.
/// </remarks>
public CropLayer(float left, float top, float right, float bottom, CropMode cropMode = CropMode.Percentage)
{
if (left < 0 || top < 0 || right < 0 || bottom < 0)
{
throw new ArgumentOutOfRangeException();
}
this.Left = left;
this.Top = top;
this.Right = right;
this.Bottom = bottom;
this.CropMode = cropMode;
}
/// <summary>
/// Gets or sets the left coordinate of the crop layer.
/// </summary>
public float Left { get; set; }
/// <summary>
/// Gets or sets the top coordinate of the crop layer.
/// </summary>
public float Top { get; set; }
/// <summary>
/// Gets or sets the right coordinate of the crop layer.
/// </summary>
public float Right { get; set; }
/// <summary>
/// Gets or sets the bottom coordinate of the crop layer.
/// </summary>
public float Bottom { get; set; }
/// <summary>
/// Gets or sets the <see cref="CropMode"/>.
/// </summary>
public CropMode CropMode { get; set; }
}
}