// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorProfiles; namespace SixLabors.ImageSharp.Tests.ColorProfiles; /// /// Tests - conversions. /// public class CieLuvAndRgbConversionTests { private static readonly ApproximateColorProfileComparer Comparer = new(.0002F); [Theory] [InlineData(0, 0, 0, 0, 0, 0)] [InlineData(36.0555, 93.6901, 10.01514, 0.6444615, 0.1086071, 0.2213444)] public void Convert_CieLuv_to_Rgb(float l, float u, float v, float r, float g, float b) { // Arrange CieLuv input = new(l, u, v); Rgb expected = new(r, g, b); ColorConversionOptions options = new() { SourceWhitePoint = KnownIlluminants.D65, TargetWhitePoint = KnownIlluminants.D65 }; ColorProfileConverter converter = new(options); Span inputSpan = new CieLuv[5]; inputSpan.Fill(input); Span actualSpan = new Rgb[5]; // Act Rgb actual = converter.Convert(input); converter.Convert(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(0.6444615, 0.1086071, 0.2213444, 36.0555, 93.69012, 10.01514)] public void Convert_Rgb_to_CieLuv(float r, float g, float b, float l, float u, float v) { // Arrange Rgb input = new(r, g, b); CieLuv expected = new(l, u, v); ColorConversionOptions options = new() { SourceWhitePoint = KnownIlluminants.D65, TargetWhitePoint = KnownIlluminants.D65 }; ColorProfileConverter converter = new(options); Span inputSpan = new Rgb[5]; inputSpan.Fill(input); Span actualSpan = new CieLuv[5]; // Act CieLuv actual = converter.Convert(input); converter.Convert(inputSpan, actualSpan); // Assert Assert.Equal(expected, actual, Comparer); for (int i = 0; i < actualSpan.Length; i++) { Assert.Equal(expected, actualSpan[i], Comparer); } } }