// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorProfiles; namespace SixLabors.ImageSharp.Tests.ColorProfiles; /// /// Tests - conversions. /// public class CieLabAndYCbCrConversionTests { private static readonly ApproximateColorProfileComparer Comparer = new(.0002F); [Theory] [InlineData(0, 128, 128, 0, 0, 0)] [InlineData(87.4179, 133.9763, 247.5308, 55.06287, 82.54838, 23.1697)] public void Convert_YCbCr_to_CieLab(float y, float cb, float cr, float l, float a, float b) { // Arrange YCbCr input = new(y, cb, cr); CieLab expected = new(l, a, b); ColorProfileConverter converter = new(); Span inputSpan = new YCbCr[5]; inputSpan.Fill(input); Span actualSpan = new CieLab[5]; // Act CieLab 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, 128, 128)] [InlineData(55.06287, 82.54838, 23.1697, 87.41701, 133.97232, 247.5314)] public void Convert_CieLab_to_YCbCr(float l, float a, float b, float y, float cb, float cr) { // Arrange CieLab input = new(l, a, b); YCbCr expected = new(y, cb, cr); ColorProfileConverter converter = new(); Span inputSpan = new CieLab[5]; inputSpan.Fill(input); Span actualSpan = new YCbCr[5]; // Act YCbCr 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); } } }