Exemple #1
0
 public TileTableModel(ImageFileIndexStructure imageFile)
 {
     Id            = imageFile.Id;
     FileName      = imageFile.FileName;
     FilePath      = imageFile.FilePath;
     LastWriteTime = imageFile.LastWriteTime;
     if (imageFile.Data != null)
     {
         var colour = Color.FromArgb(imageFile.Data.AverageWhole);
         AverageColour  = colour.ToHex();
         StandardColour = new FileColourModel().FindClosestColour(colour).ToHex();
     }
 }
        public void ReadMasterColours(IMakerClient client, ProjectResponse project, int height, int width)
        {
            // Convert the ARGB values from master file into Color objects
            var master        = client.ReadImageFile(project.Project.LargeFileId);
            var masterARGB    = client.ReadMasterFileColours(master.File, height, width);
            var masterColours = masterARGB.AverageTileARGB.Select(x => Color.FromArgb(x)).ToList();

            // Find the closest standard Color object for each color in master file colours
            var masterClosestColours    = new FileColourModel().FindClosestColour(masterColours);
            var masterClosestColoursHex = masterClosestColours.Select(x => x.ToHex()).ToList();

            var masterFileDictionary = ConvertColourListToDictionary(masterClosestColoursHex);

            MasterImageColorDictionary = masterFileDictionary;
            JsonMasterImageColours     = JsonConvert.SerializeObject(masterFileDictionary, Formatting.Indented);
            JsonMasterImageHexColours  = JsonConvert.SerializeObject(masterFileDictionary.Keys, Formatting.Indented);
        }
        public void ReadTileColours(IMakerClient client, ProjectResponse project)
        {
            // At the moment is takes into account the four quadrant averages of the file
            // rather than just one average which represents the whole tile.
            // Convert the ARGB values stored in project into Color objects
            var tiles        = client.ReadAllImageFiles(project.Project.SmallFileIds);
            var tilesColours = tiles.Files.Select(x => Color.FromArgb(x.Data.AverageWhole)).ToList();

            // Find the closest standard Color object for each color in tile files colours
            var tilesClosestColours         = new FileColourModel().FindClosestColour(tilesColours);
            var tilesFilesClosestColoursHex = tilesClosestColours.Select(x => x.ToHex()).ToList();

            var tilesDictionary = ConvertColourListToDictionary(tilesFilesClosestColoursHex);

            TileImageColorDictionary = tilesDictionary;
            JsonTileImageColours     = JsonConvert.SerializeObject(tilesDictionary, Formatting.Indented);
            JsonTileImageHexColours  = JsonConvert.SerializeObject(tilesDictionary.Keys, Formatting.Indented);
        }