|
|
@ -21,26 +21,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution |
|
|
internal class BokehBlurProcessor<TPixel> : ImageProcessor<TPixel> |
|
|
internal class BokehBlurProcessor<TPixel> : ImageProcessor<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
/// <summary>
|
|
|
|
|
|
/// The kernel radius.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly int radius; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// The gamma highlight factor to use when applying the effect
|
|
|
/// The gamma highlight factor to use when applying the effect
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private readonly float gamma; |
|
|
private readonly float gamma; |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The maximum size of the kernel in either direction
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly int kernelSize; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The number of components to use when applying the bokeh blur
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly int componentsCount; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// The kernel parameters to use for the current instance (a: X, b: Y, A: Z, B: W)
|
|
|
/// The kernel parameters to use for the current instance (a: X, b: Y, A: Z, B: W)
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
@ -61,13 +46,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution |
|
|
public BokehBlurProcessor(Configuration configuration, BokehBlurProcessor definition, Image<TPixel> source, Rectangle sourceRectangle) |
|
|
public BokehBlurProcessor(Configuration configuration, BokehBlurProcessor definition, Image<TPixel> source, Rectangle sourceRectangle) |
|
|
: base(configuration, source, sourceRectangle) |
|
|
: base(configuration, source, sourceRectangle) |
|
|
{ |
|
|
{ |
|
|
this.radius = definition.Radius; |
|
|
|
|
|
this.kernelSize = (this.radius * 2) + 1; |
|
|
|
|
|
this.componentsCount = definition.Components; |
|
|
|
|
|
this.gamma = definition.Gamma; |
|
|
this.gamma = definition.Gamma; |
|
|
|
|
|
|
|
|
// Get the bokeh blur data
|
|
|
// Get the bokeh blur data
|
|
|
BokehBlurKernelData data = BokehBlurKernelDataProvider.GetBokehBlurKernelData(this.radius, this.kernelSize, this.componentsCount); |
|
|
BokehBlurKernelData data = BokehBlurKernelDataProvider.GetBokehBlurKernelData( |
|
|
|
|
|
definition.Radius, |
|
|
|
|
|
(definition.Radius * 2) + 1, |
|
|
|
|
|
definition.Components); |
|
|
|
|
|
|
|
|
this.kernelParameters = data.Parameters; |
|
|
this.kernelParameters = data.Parameters; |
|
|
this.kernels = data.Kernels; |
|
|
this.kernels = data.Kernels; |
|
|
|