Пример #1
0
        public static CieXyzColor ToCieXyz(this LinearRgbColor source)
        {
            Vector4 rgb = new Vector4((float)source.R, (float)source.G, (float)source.B, 1.0f);
            Vector4 xyz = Vector4.Transform(rgb, linearRgbToCieTransform);

            return(new CieXyzColor
            {
                X = xyz.X,
                Y = xyz.Y,
                Z = xyz.Z
            });
        }
Пример #2
0
        public static StandardRgbColor ToStandardRgb(this LinearRgbColor source)
        {
            return(new StandardRgbColor
            {
                R = (byte)Math.Max(0, Math.Min(255, Math.Round(convertLinearToGamma(source.R) * 255))),
                G = (byte)Math.Max(0, Math.Min(255, Math.Round(convertLinearToGamma(source.G) * 255))),
                B = (byte)Math.Max(0, Math.Min(255, Math.Round(convertLinearToGamma(source.B) * 255)))
            });

            double convertLinearToGamma(double u)
            {
                return(u <= 0.003308 ? u * 12.92 : 1.055 * Math.Pow(u, 5.0 / 12.0) - 0.055);
            }
        }
Пример #3
0
 public static CieLuvColor ToCieLuv(this LinearRgbColor source)
 {
     return(source.ToCieXyz().ToCieLuv());
 }