Browse Source
Merge pull request #1332 from SixLabors/sp/bokeh-blur-init-tweaks
Bokeh blur constructor tweaks (input validation, tiny speedup)
js/color-alpha-handling
Anton Firszov
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
18 additions and
1 deletions
-
src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor.cs
-
tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs
|
|
|
@ -29,8 +29,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution |
|
|
|
/// Initializes a new instance of the <see cref="BokehBlurProcessor"/> class.
|
|
|
|
/// </summary>
|
|
|
|
public BokehBlurProcessor() |
|
|
|
: this(DefaultRadius, DefaultComponents, DefaultGamma) |
|
|
|
{ |
|
|
|
this.Radius = DefaultRadius; |
|
|
|
this.Components = DefaultComponents; |
|
|
|
this.Gamma = DefaultGamma; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -47,6 +49,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution |
|
|
|
/// </param>
|
|
|
|
public BokehBlurProcessor(int radius, int components, float gamma) |
|
|
|
{ |
|
|
|
Guard.MustBeGreaterThan(radius, 0, nameof(radius)); |
|
|
|
Guard.MustBeBetweenOrEqualTo(components, 1, 6, nameof(components)); |
|
|
|
Guard.MustBeGreaterThanOrEqualTo(gamma, 1, nameof(gamma)); |
|
|
|
|
|
|
|
this.Radius = radius; |
|
|
|
|
|
|
|
@ -35,6 +35,19 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution |
|
|
|
0.02565295+0.01611732j 0.0153483+0.01605112j 0.00698622+0.01370844j |
|
|
|
0.00135338+0.00998296j -0.00152245+0.00604545j -0.00227282+0.002851j ]]";
|
|
|
|
|
|
|
|
[Theory] |
|
|
|
[InlineData(-10, 2, 3f)] |
|
|
|
[InlineData(-1, 2, 3f)] |
|
|
|
[InlineData(0, 2, 3f)] |
|
|
|
[InlineData(20, -1, 3f)] |
|
|
|
[InlineData(20, -0, 3f)] |
|
|
|
[InlineData(20, 4, -10f)] |
|
|
|
[InlineData(20, 4, 0f)] |
|
|
|
public void VerifyBokehBlurProcessorArguments_Fail(int radius, int components, float gamma) |
|
|
|
{ |
|
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => new BokehBlurProcessor(radius, components, gamma)); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void VerifyComplexComponents() |
|
|
|
{ |
|
|
|
|