//
// 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
{
///
/// Applies a radial vignette effect to an image.
///
/// The pixel format.
/// The image this method extends.
/// The .
public static Image Vignette(this Image source)
where TColor : struct, IPixel
{
return Vignette(source, NamedColors.Black, source.Bounds.Width * .5F, source.Bounds.Height * .5F, source.Bounds);
}
///
/// Applies a radial vignette effect to an image.
///
/// The pixel format.
/// The image this method extends.
/// The color to set as the vignette.
/// The .
public static Image Vignette(this Image source, TColor color)
where TColor : struct, IPixel
{
return Vignette(source, color, source.Bounds.Width * .5F, source.Bounds.Height * .5F, source.Bounds);
}
///
/// Applies a radial vignette effect to an image.
///
/// The pixel format.
/// The image this method extends.
/// The the x-radius.
/// The the y-radius.
/// The .
public static Image Vignette(this Image source, float radiusX, float radiusY)
where TColor : struct, IPixel
{
return Vignette(source, NamedColors.Black, radiusX, radiusY, source.Bounds);
}
///
/// Applies a radial vignette effect to an image.
///
/// The pixel format.
/// The image this method extends.
///
/// The structure that specifies the portion of the image object to alter.
///
/// The .
public static Image Vignette(this Image source, Rectangle rectangle)
where TColor : struct, IPixel
{
return Vignette(source, NamedColors.Black, 0, 0, rectangle);
}
///
/// Applies a radial vignette effect to an image.
///
/// The pixel format.
/// The image this method extends.
/// The color to set as the vignette.
/// The the x-radius.
/// The the y-radius.
///
/// The structure that specifies the portion of the image object to alter.
///
/// The .
public static Image Vignette(this Image source, TColor color, float radiusX, float radiusY, Rectangle rectangle)
where TColor : struct, IPixel
{
VignetteProcessor processor = new VignetteProcessor(color) { RadiusX = radiusX, RadiusY = radiusY };
source.ApplyProcessor(processor, rectangle);
return source;
}
}
}