//
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
//
namespace ImageSharp
{
using System;
using Processing;
///
/// 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, IPackedPixel, IEquatable
{
return Vignette(source, default(TColor), 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, IPackedPixel, IEquatable
{
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, IPackedPixel, IEquatable
{
return Vignette(source, default(TColor), 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, IPackedPixel, IEquatable
{
return Vignette(source, default(TColor), 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, IPackedPixel, IEquatable
{
VignetteProcessor processor = new VignetteProcessor { RadiusX = radiusX, RadiusY = radiusY };
if (!color.Equals(default(TColor)))
{
processor.VignetteColor = color;
}
return source.Apply(rectangle, processor);
}
}
}