Esempio n. 1
0
        public static CieLabColor ToCieLab(this XyzColor xyzColor)
        {
            double x = xyzColor.X / xyzWhite.X;
            double y = xyzColor.Y / xyzWhite.Y;
            double z = xyzColor.Z / xyzWhite.Z;

            x = xyzToCieLab(x);
            y = xyzToCieLab(y);
            z = xyzToCieLab(z);

            float l = (float)((116 * y) - 16);
            float a = (float)(500 * (x - y));
            float b = (float)(200 * (y - z));

            return(new CieLabColor(l, a, b));
        }
Esempio n. 2
0
        public static RgbColor ToRgb(this XyzColor xyzColor)
        {
            double x = (double)xyzColor.X / 100d;
            double y = (double)xyzColor.Y / 100d;
            double z = (double)xyzColor.Z / 100d;

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

            r = xyzToRgb(r);
            g = xyzToRgb(g);
            b = xyzToRgb(b);

            r = r > 1 ? 1 : (r < 0 ? 0 : r);
            g = g > 1 ? 1 : (g < 0 ? 0 : g);
            b = b > 1 ? 1 : (b < 0 ? 0 : b);

            return(new RgbColor((byte)(r * 255), (byte)(g * 255), (byte)(b * 255)));
        }