mirror of https://github.com/SixLabors/ImageSharp
5 changed files with 228 additions and 3 deletions
@ -0,0 +1,70 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests <see cref="CieLab"/>-<see cref="Hsl"/> conversions.
|
|||
/// </summary>
|
|||
public class CieLabAndHslConversionTests |
|||
{ |
|||
private static readonly ApproximateColorProfileComparer Comparer = new(.0002f); |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 0, 0)] |
|||
[InlineData(336.9393, 1, 0.5, 55.063, 82.54868, 23.16508)] |
|||
public void Convert_Hsl_to_CieLab(float h, float s, float ll, float l, float a, float b) |
|||
{ |
|||
// Arrange
|
|||
Hsl input = new(h, s, ll); |
|||
CieLab expected = new(l, a, b); |
|||
ColorProfileConverter converter = new(); |
|||
|
|||
Span<Hsl> inputSpan = new Hsl[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<CieLab> actualSpan = new CieLab[5]; |
|||
|
|||
// Act
|
|||
CieLab actual = converter.Convert<Hsl, CieLab>(input); |
|||
converter.Convert<Hsl, CieLab>(inputSpan, actualSpan); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual, Comparer); |
|||
|
|||
for (int i = 0; i < actualSpan.Length; i++) |
|||
{ |
|||
Assert.Equal(expected, actualSpan[i], Comparer); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 0, 0)] |
|||
[InlineData(55.063, 82.54868, 23.16508, 336.9393, 1, 0.5)] |
|||
public void Convert_CieLab_to_Hsl(float l, float a, float b, float h, float s, float ll) |
|||
{ |
|||
// Arrange
|
|||
CieLab input = new(l, a, b); |
|||
Hsl expected = new(h, s, ll); |
|||
ColorProfileConverter converter = new(); |
|||
|
|||
Span<CieLab> inputSpan = new CieLab[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<Hsl> actualSpan = new Hsl[5]; |
|||
|
|||
// Act
|
|||
Hsl actual = converter.Convert<CieLab, Hsl>(input); |
|||
converter.Convert<CieLab, Hsl>(inputSpan, actualSpan); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual, Comparer); |
|||
|
|||
for (int i = 0; i < actualSpan.Length; i++) |
|||
{ |
|||
Assert.Equal(expected, actualSpan[i], Comparer); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests <see cref="CieLab"/>-<see cref="Hsv"/> conversions.
|
|||
/// </summary>
|
|||
public class CieLabAndHsvConversionTests |
|||
{ |
|||
private static readonly ApproximateColorProfileComparer Comparer = new(.0002f); |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 0, 0)] |
|||
[InlineData(336.9393, 1, 0.9999999, 55.063, 82.54871, 23.16504)] |
|||
public void Convert_Hsv_to_CieLab(float h, float s, float v, float l, float a, float b) |
|||
{ |
|||
// Arrange
|
|||
Hsv input = new(h, s, v); |
|||
CieLab expected = new(l, a, b); |
|||
ColorProfileConverter converter = new(); |
|||
|
|||
Span<Hsv> inputSpan = new Hsv[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<CieLab> actualSpan = new CieLab[5]; |
|||
|
|||
// Act
|
|||
CieLab actual = converter.Convert<Hsv, CieLab>(input); |
|||
converter.Convert<Hsv, CieLab>(inputSpan, actualSpan); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual, Comparer); |
|||
|
|||
for (int i = 0; i < actualSpan.Length; i++) |
|||
{ |
|||
Assert.Equal(expected, actualSpan[i], Comparer); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 0, 0)] |
|||
[InlineData(55.063, 82.54871, 23.16504, 336.9393, 1, 0.9999999)] |
|||
public void Convert_CieLab_to_Hsv(float l, float a, float b, float h, float s, float v) |
|||
{ |
|||
// Arrange
|
|||
CieLab input = new(l, a, b); |
|||
Hsv expected = new(h, s, v); |
|||
ColorProfileConverter converter = new(); |
|||
|
|||
Span<CieLab> inputSpan = new CieLab[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<Hsv> actualSpan = new Hsv[5]; |
|||
|
|||
// Act
|
|||
Hsv actual = converter.Convert<CieLab, Hsv>(input); |
|||
converter.Convert<CieLab, Hsv>(inputSpan, actualSpan); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual, Comparer); |
|||
|
|||
for (int i = 0; i < actualSpan.Length; i++) |
|||
{ |
|||
Assert.Equal(expected, actualSpan[i], Comparer); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests <see cref="CieLab"/>-<see cref="HunterLab"/> conversions.
|
|||
/// </summary>
|
|||
public class CieLabAndHunterLabConversionTests |
|||
{ |
|||
private static readonly ApproximateColorProfileComparer Comparer = new(.0002f); |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 0, 0)] |
|||
[InlineData(27.51646, 556.9392, -0.03974226, 33.074177, 281.48329, -0.06948)] |
|||
public void Convert_HunterLab_to_CieLab(float l2, float a2, float b2, float l, float a, float b) |
|||
{ |
|||
// Arrange
|
|||
HunterLab input = new(l2, a2, b2); |
|||
CieLab expected = new(l, a, b); |
|||
ColorProfileConverter converter = new(); |
|||
|
|||
Span<HunterLab> inputSpan = new HunterLab[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<CieLab> actualSpan = new CieLab[5]; |
|||
|
|||
// Act
|
|||
CieLab actual = converter.Convert<HunterLab, CieLab>(input); |
|||
converter.Convert<HunterLab, CieLab>(inputSpan, actualSpan); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual, Comparer); |
|||
|
|||
for (int i = 0; i < actualSpan.Length; i++) |
|||
{ |
|||
Assert.Equal(expected, actualSpan[i], Comparer); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 0, 0)] |
|||
[InlineData(33.074177, 281.48329, -0.06948, 27.51646, 556.9392, -0.03974226)] |
|||
public void Convert_CieLab_to_HunterLab(float l, float a, float b, float l2, float a2, float b2) |
|||
{ |
|||
// Arrange
|
|||
CieLab input = new(l, a, b); |
|||
HunterLab expected = new(l2, a2, b2); |
|||
ColorProfileConverter converter = new(); |
|||
|
|||
Span<CieLab> inputSpan = new CieLab[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<HunterLab> actualSpan = new HunterLab[5]; |
|||
|
|||
// Act
|
|||
HunterLab actual = converter.Convert<CieLab, HunterLab>(input); |
|||
converter.Convert<CieLab, HunterLab>(inputSpan, actualSpan); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual, Comparer); |
|||
|
|||
for (int i = 0; i < actualSpan.Length; i++) |
|||
{ |
|||
Assert.Equal(expected, actualSpan[i], Comparer); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue