コード例 #1
0
        /// <summary>
        /// Color conversion
        /// The ColourfulConverter facade can convert from any of the supported color spaces to any other color space.
        /// It always performs the chromatic adaptation if the input and output color space white points are different.
        /// </summary>
        private void ColorConversion()
        {
            RGBColor input = new RGBColor(1, 0, 0);

            var converter = new ColourfulConverter {
                WhitePoint = Illuminants.D50
            };

            XYZColor output = converter.ToXYZ(input);
        } // end ColorConversion
コード例 #2
0
        public void Convert_Lab_to_XYZ(DataRow row)
        {
            var inputLab    = row.GetLabColor();
            var expectedXYZ = row.GetXYZColor();
            var actualXYZ   = _converter.ToXYZ(inputLab);

            try
            {
                Assert.That(actualXYZ, Is.EqualTo(expectedXYZ)
                            .Using(new ColorVectorComparer(new DoubleDeltaComparer(0.000001))));
            }
            catch (AssertionException ex) { RethrowException(ex, row); }
        }
コード例 #3
0
        public void Convert_xyY_to_XYZ(double xyzX, double xyzY, double xyzZ, double x, double y, double Y)
        {
            // arrange
            var input     = new xyYColor(x, y, Y);
            var converter = new ColourfulConverter();

            // act
            XYZColor output = converter.ToXYZ(input);

            // assert
            Assert.That(output.X, Is.EqualTo(xyzX).Using(DoubleComparer));
            Assert.That(output.Y, Is.EqualTo(xyzY).Using(DoubleComparer));
            Assert.That(output.Z, Is.EqualTo(xyzZ).Using(DoubleComparer));
        }
コード例 #4
0
        public void Convert_xyY_to_XYZ(double xyzX, double xyzY, double xyzZ, double x, double y, double Y)
        {
            // arrange
            var input     = new xyYColor(x, y, Y);
            var converter = new ColourfulConverter();

            // act
            var output = converter.ToXYZ(input);

            // assert
            Assert.Equal(output.X, xyzX, DoubleComparer);
            Assert.Equal(output.Y, xyzY, DoubleComparer);
            Assert.Equal(output.Z, xyzZ, DoubleComparer);
        }
コード例 #5
0
        public void Convert_XYZ_as_vector_to_XYZ(double x, double y, double z)
        {
            // arrange
            IColorVector input = new XYZColor(x, y, z);

            var converter = new ColourfulConverter();

            // act
            XYZColor output = converter.ToXYZ(input);

            // assert
            Assert.That(output.X, Is.EqualTo(x).Using(DoubleComparer));
            Assert.That(output.Y, Is.EqualTo(y).Using(DoubleComparer));
            Assert.That(output.Z, Is.EqualTo(z).Using(DoubleComparer));
        }
コード例 #6
0
        public void Convert_XYZ_as_vector_to_XYZ(double x, double y, double z)
        {
            // arrange
            IColorVector input = new XYZColor(x, y, z);

            var converter = new ColourfulConverter();

            // act
            var output = converter.ToXYZ(input);

            // assert
            Assert.Equal(output.X, x, DoubleComparer);
            Assert.Equal(output.Y, y, DoubleComparer);
            Assert.Equal(output.Z, z, DoubleComparer);
        }
コード例 #7
0
        public void Convert_sRGB_to_XYZ_D50(double r, double g, double b, double x, double y, double z)
        {
            // arrange
            var input     = new RGBColor(r, g, b);
            var converter = new ColourfulConverter {
                WhitePoint = Illuminants.D50
            };

            // act
            var output = converter.ToXYZ(input);

            // assert
            Assert.Equal(output.X, x, DoubleComparer);
            Assert.Equal(output.Y, y, DoubleComparer);
            Assert.Equal(output.Z, z, DoubleComparer);
        }
コード例 #8
0
        public void Convert_Lab_to_XYZ(double l, double a, double b, double x, double y, double z)
        {
            // arrange
            var input     = new LabColor(l, a, b, Illuminants.D65);
            var converter = new ColourfulConverter {
                WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65
            };

            // act
            var output = converter.ToXYZ(input);

            // assert
            Assert.Equal(output.X, x, DoubleComparerXYZPrecision);
            Assert.Equal(output.Y, y, DoubleComparerXYZPrecision);
            Assert.Equal(output.Z, z, DoubleComparerXYZPrecision);
        }
コード例 #9
0
        public void Convert_Lab_to_XYZ(double l, double a, double b, double x, double y, double z)
        {
            // arrange
            var input     = new LabColor(l, a, b, Illuminants.D65);
            var converter = new ColourfulConverter {
                WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65
            };

            // act
            XYZColor output = converter.ToXYZ(input);

            // assert
            Assert.That(output.X, Is.EqualTo(x).Using(DoubleComparerXYZPrecision));
            Assert.That(output.Y, Is.EqualTo(y).Using(DoubleComparerXYZPrecision));
            Assert.That(output.Z, Is.EqualTo(z).Using(DoubleComparerXYZPrecision));
        }
コード例 #10
0
        public void Convert_sRGB_to_XYZ_D65(double r, double g, double b, double x, double y, double z)
        {
            // arrange
            var input     = new RGBColor(r, g, b);
            var converter = new ColourfulConverter {
                WhitePoint = Illuminants.D65
            };

            // act
            XYZColor output = converter.ToXYZ(input);

            // assert
            Assert.That(output.X, Is.EqualTo(x).Using(DoubleComparer));
            Assert.That(output.Y, Is.EqualTo(y).Using(DoubleComparer));
            Assert.That(output.Z, Is.EqualTo(z).Using(DoubleComparer));
        }