public static void SaveAtlasFile(Dictionary <string, Atlas> atlases, string path, AtlasFormat format)
        {
            switch (format)
            {
            case AtlasFormat.NONE: break;

            case AtlasFormat.LIBGDX: SaveLibgdxFile(atlases, path); break;
            }
        }
Beispiel #2
0
        public static void QuickCreate(string inputDir, string outputDir, int maxSize = 1024, bool recursive = true, AtlasFormat format = AtlasFormat.NONE)
        {
            Console.WriteLine("Loading images");
            string[] images = Directory.GetFiles(inputDir).Where(x => Regex.IsMatch(x.ToLower(), ImageRegex)).ToArray();

            string atlasName = Path.GetFullPath(inputDir).Substring(inputDir.LastIndexOf(Path.DirectorySeparatorChar) + 1);

            BitmapExtended[] textures = images.Select(x => new BitmapExtended(x)).ToArray();

            if (recursive)
            {
                string[] subDirs = Directory.GetDirectories(inputDir);
                for (int i = 0; i < subDirs.Length; ++i)
                {
                    textures = textures.Concat(LoadImagesR(subDirs[i], inputDir)).ToArray();
                }
            }

            AtlasCreator.AtlasSize = maxSize;

            Console.WriteLine("Creating Atlas");
            AtlasCreator.Atlas[]       atlases          = AtlasCreator.CreateAtlas(atlasName, textures);
            Dictionary <string, Atlas> atlasesWithNames = new Dictionary <string, Atlas>();

            Console.WriteLine("Saving Atlas");
            for (int i = 0; i < atlases.Length; ++i)
            {
                // build name
                string sheetName = i == 0 ? string.Format("{0}.png", atlasName) :
                                   string.Format("{0}{1}.png", atlasName, i);
                atlasesWithNames.Add(sheetName, atlases[i]);

                // create atlas
                AtlasCreator.SaveAtlas(atlases[i], outputDir, sheetName);

                // create descriptor
                SaveAtlasFile(atlasesWithNames, outputDir, format);
            }
        }