예제 #1
0
        public ColorTable(string palettedata)
        {
            Colors = new Dictionary <string, ColorRecord>();
            string[] lines = palettedata.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var line in lines)
            {
                if (line.StartsWith("COLS"))
                {
                    COLS     = RleParser.StripLenFromString(line.Substring(4).Trim()).Trim(RleParser.Term); //TODO: what does it mean?
                    Name     = line.Trim(RleParser.Term).Substring(line.LastIndexOf("NIL") + 3);
                    ObjectId = Convert.ToInt32(COLS.Substring(2, 5));
                }
                if (line.StartsWith("CCIE"))
                {
                    // Yxy -> XYZ conversion
                    double x = double.Parse(
                        RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(
                            5).Split(RleParser.Term)[0], CultureInfo.InvariantCulture);
                    double y = double.Parse(line.Trim().Split(RleParser.Term)[1],
                                            CultureInfo.InvariantCulture);
                    double Y = double.Parse(line.Trim().Split(RleParser.Term)[2],
                                            CultureInfo.InvariantCulture);

                    CIEYxy color = new CIEYxy(Y, x, y);
                    Colors.Add(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(0, 5),
                               new ColorRecord(RleParser.StripLenFromString(line.Substring(4).Trim()).Substring(0, 5),
                                               line.Trim().Split(RleParser.Term)[3], color
                                               ));
                }
            }
        }
예제 #2
0
 public ColorRecord(string code, string name, CIEYxy cieyxy)
 {
     Code = code;
     Name = name;
     Yxy  = cieyxy;
 }