示例#1
0
        protected static void ExpectedValuesForKnownColor(IColorSpace knownColor, IXyz expectedColor)
        {
            var target = knownColor.To<Xyz>();

            Assert.IsTrue(CloseEnough(expectedColor.X,target.X),"(X)" + expectedColor.X + " != " + target.X);
            Assert.IsTrue(CloseEnough(expectedColor.Y,target.Y),"(Y)" + expectedColor.Y + " != " + target.Y);
            Assert.IsTrue(CloseEnough(expectedColor.Z,target.Z),"(Z)" + expectedColor.Z + " != " + target.Z);
        }
示例#2
0
        protected static void ExpectedValuesForKnownColor(IColorSpace knownColor, IXyz expectedColor)
        {
            var target = knownColor.To <Xyz>();

            Assert.AreEqual(expectedColor.X, target.X, 0.5, "(X)" + expectedColor.X + " != " + target.X);
            Assert.AreEqual(expectedColor.Y, target.Y, 0.5, "(Y)" + expectedColor.Y + " != " + target.Y);
            Assert.AreEqual(expectedColor.Z, target.Z, 0.5, "(Z)" + expectedColor.Z + " != " + target.Z);
        }
示例#3
0
 internal const double Kappa = 903.3; // Intent is 24389/27
 static XyzConverter()
 {
     WhiteReference = new Xyz
     {
         X = 95.047,
         Y = 100.000,
         Z = 108.883
     };
 }
示例#4
0
        internal static void ToColorSpace(IRgb color, IXyz item)
        {
            var r = PivotRgb(color.R / 255.0);
            var g = PivotRgb(color.G / 255.0);
            var b = PivotRgb(color.B / 255.0);

            // Observer. = 2°, Illuminant = D65
            item.X = r * 0.4124 + g * 0.3576 + b * 0.1805;
            item.Y = r * 0.2126 + g * 0.7152 + b * 0.0722;
            item.Z = r * 0.0193 + g * 0.1192 + b * 0.9505;
        }
示例#5
0
        internal static IRgb ToColor(IXyz item)
        {
            // (Observer = 2°, Illuminant = D65)
            var x = item.X / 100.0;
            var y = item.Y / 100.0;
            var z = item.Z / 100.0;

            var r = x * 3.2406 + y * -1.5372 + z * -0.4986;
            var g = x * -0.9689 + y * 1.8758 + z * 0.0415;
            var b = x * 0.0557 + y * -0.2040 + z * 1.0570;

            r = r > 0.0031308 ? 1.055 * Math.Pow(r, 1 / 2.4) - 0.055 : 12.92 * r;
            g = g > 0.0031308 ? 1.055 * Math.Pow(g, 1 / 2.4) - 0.055 : 12.92 * g;
            b = b > 0.0031308 ? 1.055 * Math.Pow(b, 1 / 2.4) - 0.055 : 12.92 * b;

            return new Rgb
            {
                R = ToRgb(r),
                G = ToRgb(g),
                B = ToRgb(b)
            };
        }
示例#6
0
 private static double GetDenominator(IXyz xyz)
 {
     return xyz.X + 15.0 * xyz.Y + 3.0 * xyz.Z;
 }
示例#7
0
 public XyzColor(IXyz xyz)
 {
     Ordinals = xyz.Ordinals;
 }
示例#8
0
 public HunterLabColor(IXyz xyz)
 {
     Initialize(xyz.ToRgb());
 }
 public void Bar(IXyz xyz)
 {
     xyz.Foo();
 }