//
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
//
namespace ImageProcessorCore
{
using System;
using 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 packed format. uint, long, float.
/// The image this method extends.
/// The number of intensity levels. Higher values result in a broader range of colour intensities forming part of the result image.
/// The number of neighbouring 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, IPackedPixel
where TPacked : struct
{
return OilPaint(source, levels, brushSize, source.Bounds);
}
///
/// Alters the colors of the image recreating an oil painting effect.
///
/// The pixel format.
/// The packed format. uint, long, float.
/// The image this method extends.
/// The number of intensity levels. Higher values result in a broader range of colour intensities forming part of the result image.
/// The number of neighbouring 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, IPackedPixel
where TPacked : struct
{
Guard.MustBeGreaterThan(levels, 0, nameof(levels));
if (brushSize <= 0 || brushSize > source.Height || brushSize > source.Width)
{
throw new ArgumentOutOfRangeException(nameof(brushSize));
}
return source.Process(rectangle, new OilPaintingProcessor(levels, brushSize));
}
}
}