Beispiel #1
0
        public ValueTuple <int, int, int>[][,] LoadJsonGif(string gif)
        {
            Console.WriteLine("Loading Json");
            (int, int, int)tup;
            string path = System.IO.File.ReadAllText(@"C:\Users\Zak Body\source\repos\Launchpad-Z\LaunchpadZ\LPImages.json");

            if (GetImages().Contains(gif))
            {
                JObject json = JObject.Parse(path);
                JToken  data = json[gif]["data"];
                ValueTuple <int, int, int>[][,] rgbValues = new ValueTuple <int, int, int> [json[gif]["data"].Count()][, ];

                for (int i = 0; i < json[gif]["data"].Count(); i++)
                {
                    rgbValues[i] = new ValueTuple <int, int, int> [8, 8];
                }


                //ValueTuple<int, int, int>[][,] rgbValues = new ValueTuple<int, int, int>[2][,];

                for (int frame = 0; frame < rgbValues.Count(); frame++)
                {
                    for (int i = 0; i < data[frame].Count(); i++)
                    {
                        for (int j = 0; j < data[frame][i].Count(); j++)
                        {
                            tup.Item1 = (int)data[frame][i][j][0];
                            tup.Item2 = (int)data[frame][i][j][1];
                            tup.Item3 = (int)data[frame][i][j][2];
                            rgbValues[frame][i, j] = tup;
                        }
                    }
                }
                return(rgbValues);
            }
            else
            {
                ValueTuple <int, int, int>[][,] rgbValues = new ValueTuple <int, int, int> [0][, ];
                return(rgbValues);
            }
        }