//
// 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
{
///
/// Alters the colors of the image recreating an oil painting effect.
///
/// The pixel format.
/// The image this method extends.
/// The number of intensity levels. Higher values result in a broader range of color intensities forming part of the result image.
/// The number of neighboring pixels used in calculating each individual pixel value.
/// The .
public static Image OilPaint(this Image source, int levels = 10, int brushSize = 15)
where TColor : struct, IPixel
{
return OilPaint(source, levels, brushSize, source.Bounds);
}
///
/// Alters the colors of the image recreating an oil painting effect.
///
/// The pixel format.
/// The image this method extends.
/// The number of intensity levels. Higher values result in a broader range of color intensities forming part of the result image.
/// The number of neighboring pixels used in calculating each individual pixel value.
///
/// The structure that specifies the portion of the image object to alter.
///
/// The .
public static Image OilPaint(this Image source, int levels, int brushSize, Rectangle rectangle)
where TColor : struct, IPixel
{
Guard.MustBeGreaterThan(levels, 0, nameof(levels));
if (brushSize <= 0 || brushSize > source.Height || brushSize > source.Width)
{
throw new ArgumentOutOfRangeException(nameof(brushSize));
}
source.ApplyProcessor(new OilPaintingProcessor(levels, brushSize), rectangle);
return source;
}
}
}