|
|
|
@ -29,8 +29,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void NormalBlendFunction<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = PorterDuffFunctions.NormalSrcOver((TPixel)back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = PorterDuffFunctions.NormalSrcOver(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -38,8 +38,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void NormalBlendFunctionBlender<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.NormalSrcOver().Blend(back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.NormalSrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
{ |
|
|
|
var dest = new Span<TPixel>(new TPixel[1]); |
|
|
|
new DefaultPixelBlenders<TPixel>.NormalSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); |
|
|
|
VectorAssert.Equal(expected, dest[0], 2); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), dest[0], 2); |
|
|
|
} |
|
|
|
|
|
|
|
public static TheoryData<object, object, float, object> MultiplyFunctionData = new TheoryData<object, object, float, object> { |
|
|
|
@ -68,8 +68,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void MultiplyFunction<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = PorterDuffFunctions.MultiplySrcOver((TPixel)back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = PorterDuffFunctions.MultiplySrcOver(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -77,8 +77,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void MultiplyFunctionBlender<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.MultiplySrcOver().Blend(back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.MultiplySrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
{ |
|
|
|
var dest = new Span<TPixel>(new TPixel[1]); |
|
|
|
new DefaultPixelBlenders<TPixel>.MultiplySrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); |
|
|
|
VectorAssert.Equal(expected, dest[0], 2); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), dest[0], 2); |
|
|
|
} |
|
|
|
|
|
|
|
public static TheoryData<object, object, float, object> AddFunctionData = new TheoryData<object, object, float, object> { |
|
|
|
@ -107,8 +107,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void AddFunction<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = PorterDuffFunctions.AddSrcOver((TPixel)back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = PorterDuffFunctions.AddSrcOver(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -116,8 +116,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void AddFunctionBlender<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.AddSrcOver().Blend(back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.AddSrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -127,7 +127,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
{ |
|
|
|
var dest = new Span<TPixel>(new TPixel[1]); |
|
|
|
new DefaultPixelBlenders<TPixel>.AddSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); |
|
|
|
VectorAssert.Equal(expected, dest[0], 2); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), dest[0], 2); |
|
|
|
} |
|
|
|
|
|
|
|
public static TheoryData<object, object, float, object> SubtractFunctionData = new TheoryData<object, object, float, object> { |
|
|
|
@ -146,8 +146,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void SubtractFunction<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = PorterDuffFunctions.SubtractSrcOver((TPixel)back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = PorterDuffFunctions.SubtractSrcOver(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -155,8 +155,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void SubtractFunctionBlender<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.SubtractSrcOver().Blend(back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.SubtractSrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -166,7 +166,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
{ |
|
|
|
var dest = new Span<TPixel>(new TPixel[1]); |
|
|
|
new DefaultPixelBlenders<TPixel>.SubtractSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); |
|
|
|
VectorAssert.Equal(expected, dest[0], 2); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), dest[0], 2); |
|
|
|
} |
|
|
|
|
|
|
|
public static TheoryData<object, object, float, object> ScreenFunctionData = new TheoryData<object, object, float, object> { |
|
|
|
@ -185,8 +185,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void ScreenFunction<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = PorterDuffFunctions.ScreenSrcOver((TPixel)back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = PorterDuffFunctions.ScreenSrcOver(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -194,8 +194,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void ScreenFunctionBlender<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.ScreenSrcOver().Blend(back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.ScreenSrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -205,7 +205,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
{ |
|
|
|
var dest = new Span<TPixel>(new TPixel[1]); |
|
|
|
new DefaultPixelBlenders<TPixel>.ScreenSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); |
|
|
|
VectorAssert.Equal(expected, dest[0], 2); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), dest[0], 2); |
|
|
|
} |
|
|
|
|
|
|
|
public static TheoryData<object, object, float, object> DarkenFunctionData = new TheoryData<object, object, float, object> { |
|
|
|
@ -224,8 +224,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void DarkenFunction<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = PorterDuffFunctions.DarkenSrcOver((TPixel)back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = PorterDuffFunctions.DarkenSrcOver(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -233,8 +233,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void DarkenFunctionBlender<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.DarkenSrcOver().Blend(back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.DarkenSrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -244,7 +244,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
{ |
|
|
|
var dest = new Span<TPixel>(new TPixel[1]); |
|
|
|
new DefaultPixelBlenders<TPixel>.DarkenSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); |
|
|
|
VectorAssert.Equal(expected, dest[0], 2); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), dest[0], 2); |
|
|
|
} |
|
|
|
|
|
|
|
public static TheoryData<object, object, float, object> LightenFunctionData = new TheoryData<object, object, float, object> { |
|
|
|
@ -263,8 +263,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void LightenFunction<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = PorterDuffFunctions.LightenSrcOver((TPixel)back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = PorterDuffFunctions.LightenSrcOver(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -272,8 +272,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void LightenFunctionBlender<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.LightenSrcOver().Blend(back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.LightenSrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -283,7 +283,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
{ |
|
|
|
var dest = new Span<TPixel>(new TPixel[1]); |
|
|
|
new DefaultPixelBlenders<TPixel>.LightenSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); |
|
|
|
VectorAssert.Equal(expected, dest[0], 2); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), dest[0], 2); |
|
|
|
} |
|
|
|
|
|
|
|
public static TheoryData<object, object, float, object> OverlayFunctionData = new TheoryData<object, object, float, object> { |
|
|
|
@ -302,8 +302,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void OverlayFunction<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = PorterDuffFunctions.OverlaySrcOver((TPixel)back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = PorterDuffFunctions.OverlaySrcOver(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -311,8 +311,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void OverlayFunctionBlender<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.OverlaySrcOver().Blend(back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.OverlaySrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -322,7 +322,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
{ |
|
|
|
var dest = new Span<TPixel>(new TPixel[1]); |
|
|
|
new DefaultPixelBlenders<TPixel>.OverlaySrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); |
|
|
|
VectorAssert.Equal(expected, dest[0], 2); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), dest[0], 2); |
|
|
|
} |
|
|
|
|
|
|
|
public static TheoryData<object, object, float, object> HardLightFunctionData = new TheoryData<object, object, float, object> { |
|
|
|
@ -341,8 +341,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void HardLightFunction<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = PorterDuffFunctions.HardLightSrcOver((TPixel)back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = PorterDuffFunctions.HardLightSrcOver(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -350,8 +350,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
public void HardLightFunctionBlender<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.HardLightSrcOver().Blend(back, source, amount); |
|
|
|
VectorAssert.Equal(expected, actual, 2); |
|
|
|
TPixel actual = new DefaultPixelBlenders<TPixel>.HardLightSrcOver().Blend(back.AsPixel(), source.AsPixel(), amount); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), actual, 2); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
@ -361,7 +361,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders |
|
|
|
{ |
|
|
|
var dest = new Span<TPixel>(new TPixel[1]); |
|
|
|
new DefaultPixelBlenders<TPixel>.HardLightSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); |
|
|
|
VectorAssert.Equal(expected, dest[0], 2); |
|
|
|
VectorAssert.Equal(expected.AsPixel(), dest[0], 2); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|