Beispiel #1
0
 public void AddColor(CColor color)
 {
     this.m_colors.Add(color);
 }
Beispiel #2
0
        private bool BuildColorConfig(List <CColor> colors)
        {
            for (int i = 0; i < m_colorlines.Count; i++)
            {
                CColor color = new CColor();
                for (int j = 0; j < m_colorlines[i].lines.Count; j++)
                {
                    string line = m_colorlines[i].lines[j].line;
                    string key, value;

                    Util.GetWord(ref line, out key);
                    Util.GetWord(ref line, out value);

                    if (key == "name")
                    {
                        color.Name = value;
                    }
                    else if (key == "rgb")
                    {
                        int     irgb;
                        float[] frgb = new float[3];

                        irgb = int.Parse(value, NumberStyles.HexNumber, null);

                        for (int k = 0; k < 3; k++)
                        {
                            frgb[k] = (float)(((irgb >> ((2 - k) * 8)) & 0xFF) / 255.0);
                        }

                        color.Rgb = frgb;
                    }
                    else if (key == "gamma")
                    {
                        float gamma;
                        Util.ConvertFloatLocale(ref value);
                        gamma         = float.Parse(value);
                        color.m_gamma = gamma;
                    }
                    else if (key == "adjust")
                    {
                        float adjust;
                        Util.ConvertFloatLocale(ref value);
                        adjust         = float.Parse(value);
                        color.m_adjust = adjust;
                    }
                    else if (key == "blacklevel")
                    {
                        float blacklevel;
                        Util.ConvertFloatLocale(ref value);
                        blacklevel         = float.Parse(value);
                        color.m_blacklevel = blacklevel;
                    }
                }

                //we need at least a name for a color
                if (String.IsNullOrEmpty(color.Name))
                {
                    Util.LogError($"{m_filename}: color {i + 1} has no name");
                    return(false);
                }

                colors.Add(color);
            }

            return(true);
        }