Example #1
0
        public RgbColor ToRgb(RgbType type = RgbType.Normalized)
        {
            var color     = ToCmyk(CmykType.CmyNormalized);
            var converted = new RgbColor();

            converted.R = 1 - color.c;
            converted.G = 1 - color.m;
            converted.B = 1 - color.y;
            return(converted.ToRgb(type));
        }
Example #2
0
        public RgbColor ToRgb(RgbType type = RgbType.Normalized)
        {
            float[] colors    = { x, y, z };
            var     converted = new RgbColor();

            for (int i = 0; i < 3; i++)
            {
                converted.R += rgbmatconv[0, i] * colors[i];
                converted.G += rgbmatconv[1, i] * colors[i];
                converted.B += rgbmatconv[2, i] * colors[i];
            }
            return(converted.ToRgb(type));
        }
Example #3
0
        public RgbColor ToRgb(RgbType type = RgbType.Normalized)
        {
            float[] colors    = { y, i, q };
            var     converted = new RgbColor();

            for (int j = 0; j < 3; j++)
            {
                converted.R += rgbmatconv[0, j] * colors[j];
                converted.G += rgbmatconv[1, j] * colors[j];
                converted.B += rgbmatconv[2, j] * colors[j];
            }
            return(converted.ToRgb(type));
        }
Example #4
0
        public RgbColor ToRgb(RgbType type = RgbType.Normalized)
        {
            float    hh, p, q, t, ff;
            long     i;
            RgbColor res = new RgbColor();

            if (this.s <= 0.0)
            {       // < is bogus, just shuts up warnthisgs
                res.R = this.v;
                res.G = this.v;
                res.B = this.v;
                return(res);
            }
            hh = this.h;
            if (hh >= 360.0)
            {
                hh = 0.0F;
            }
            hh /= 60.0F;
            i   = (long)hh;
            ff  = hh - i;
            p   = this.v * (1.0F - this.s);
            q   = this.v * (1.0F - (this.s * ff));
            t   = this.v * (1.0F - (this.s * (1.0F - ff)));

            switch (i)
            {
            case 0:
                res.R = this.v;
                res.G = t;
                res.B = p;
                break;

            case 1:
                res.R = q;
                res.G = this.v;
                res.B = p;
                break;

            case 2:
                res.R = p;
                res.G = this.v;
                res.B = t;
                break;

            case 3:
                res.R = p;
                res.G = q;
                res.B = this.v;
                break;

            case 4:
                res.R = t;
                res.G = p;
                res.B = this.v;
                break;

            case 5:
            default:
                res.R = this.v;
                res.G = p;
                res.B = q;
                break;
            }
            return(res.ToRgb(type));
        }