public void Run(string[] args) { // Print the exe header PrintHeader(); foreach (String s in args) Console.WriteLine(s); Console.WriteLine(""); // Parse the command line if (!ParseCommandLine(args)) { Environment.Exit(-1); } // Check if we have a pattern InputPatternFile = Path.Combine(Environment.CurrentDirectory, InputPatternFile); int indexOfPattern = InputPatternFile.IndexOf('*'); bool isPattern = indexOfPattern >= 0; if (!isPattern) { InputPatternFile = Path.GetFullPath(InputPatternFile); } OutputFileOrDirectory = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, OutputFileOrDirectory)); var inputOutputFiles = new List<Tuple<string, string>>(); if (isPattern) { if (!Directory.Exists(OutputFileOrDirectory)) { Directory.CreateDirectory(OutputFileOrDirectory); } var directory = InputPatternFile.Substring(0, indexOfPattern); var pattern = InputPatternFile.Substring(indexOfPattern, InputPatternFile.Length - indexOfPattern); foreach (var file in Directory.EnumerateFiles(directory, pattern, SearchOption.AllDirectories)) { var outputFile = Path.Combine(OutputFileOrDirectory, file.Substring(directory.Length, file.Length - directory.Length)); bool excludeFile = false; foreach (var excludeItem in ExcludeList) { if (file.IndexOf(excludeItem, StringComparison.InvariantCultureIgnoreCase) >= 0) { excludeFile = true; break; } } if (!excludeFile) { inputOutputFiles.Add(new Tuple<string, string>(file, outputFile)); } } } else { inputOutputFiles.Add(new Tuple<string, string>(InputPatternFile, OutputFileOrDirectory)); } var texTool = new TextureTool(); GlobalLogger.GlobalMessageLogged += new ConsoleLogListener(); bool hasErrors = false; foreach (var inputOutputFile in inputOutputFiles) { var inputFile = inputOutputFile.Item1; var outputFile = inputOutputFile.Item2; TexImage image = null; try { image = texTool.Load(inputFile, IsSRgb); HandleResizing(texTool, image); if (FlipOrientation.HasValue) texTool.Flip(image, FlipOrientation.Value); if (MipMap) texTool.GenerateMipMaps(image, MipMapFilter); if(PreMulAlpha) texTool.PreMultiplyAlpha(image); if(TextureFormat.HasValue) texTool.Compress(image, TextureFormat.Value); texTool.Save(image, outputFile, MipMapSize); } catch (TextureToolsException) { hasErrors = true; } finally { if(image!=null) image.Dispose(); } } texTool.Dispose(); if (hasErrors) { //Environment.Exit(-1); } }