// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Processors.Convolution { /// /// Applies bokeh blur processing to the image. /// public sealed class BokehBlurProcessor : IImageProcessor { /// /// The default radius used by the parameterless constructor. /// public const int DefaultRadius = 32; /// /// The default component count used by the parameterless constructor. /// public const int DefaultComponents = 2; /// /// The default gamma used by the parameterless constructor. /// public const float DefaultGamma = 3F; /// /// Initializes a new instance of the class. /// public BokehBlurProcessor() : this(DefaultRadius, DefaultComponents, DefaultGamma) { } /// /// Initializes a new instance of the class. /// /// /// The 'radius' value representing the size of the area to sample. /// /// /// The number of components to use to approximate the original 2D bokeh blur convolution kernel. /// /// /// The gamma highlight factor to use to further process the image. /// public BokehBlurProcessor(int radius, int components, float gamma) { Guard.MustBeGreaterThanOrEqualTo(gamma, 1, nameof(gamma)); this.Radius = radius; this.Components = components; this.Gamma = gamma; } /// /// Gets the radius. /// public int Radius { get; } /// /// Gets the number of components. /// public int Components { get; } /// /// Gets the gamma highlight factor to use when applying the effect. /// public float Gamma { get; } /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) where TPixel : struct, IPixel => new BokehBlurProcessor(configuration, this, source, sourceRectangle); } }