Example #1
0
        public static CIEXYZColour FromRGB(RGBColor rgb, CIERGBDefinition primaries)
        {
            var mat    = primaries.rgb2xyz;
            var rgbvec = DenseVector.OfArray(new double[] { rgb.r, rgb.g, rgb.b });
            var xyz    = mat * rgbvec;

            return(new CIEXYZColour(xyz[0], xyz[1], xyz[2]));
        }
Example #2
0
        public RGBColor ToRGB(CIERGBDefinition primaries, bool limitGamut = true)
        {
            // NOTE: Assumes linear RGB, not sRGB.
            var mat = primaries.xyz2rgb;
            var rgb = mat * this;

            if (limitGamut && (rgb.Maximum() > 1.0 || rgb.Minimum() < 0.0))
            {
                // Outside the gamut
                return(new RGBColor(float.NaN, float.NaN, float.NaN));
            }
            else
            {
                return(new RGBColor((float)rgb[0], (float)rgb[1], (float)rgb[2]));
            }
        }
Example #3
0
        public RGBColor ToRGB(CIERGBDefinition primaries, bool limitGamut = true)
        {
            // NOTE: Assumes linear RGB, not sRGB.
            var mat = primaries.xyz2rgb;
            var rgb = mat * this;

            if (limitGamut && (rgb.Maximum() > 1.0 || rgb.Minimum() < 0.0))
            {
                // Outside the gamut
                return new RGBColor(float.NaN, float.NaN, float.NaN);
            }
            else
            {
                return new RGBColor((float)rgb[0], (float)rgb[1], (float)rgb[2]);
            }
        }
Example #4
0
 public static CIEXYZColour FromRGB(RGBColor rgb, CIERGBDefinition primaries)
 {
     var mat = primaries.rgb2xyz;
     var rgbvec = DenseVector.OfArray(new double[] { rgb.r, rgb.g, rgb.b });
     var xyz = mat * rgbvec;
     return new CIEXYZColour(xyz[0], xyz[1], xyz[2]);
 }