public static ChunkyConfig32bit LoadConfig(string pathToConfig, bool treatAsName = false) { ChunkyConfig32bit result = new ChunkyConfig32bit(); if (treatAsName) { pathToConfig = Path.Combine(SavedConfigsPath, pathToConfig); } try { result = FileHelper.DeserializeFromJson <ChunkyConfig32bit>(pathToConfig); } catch (Exception e) { Print.Line(e); Print.Line(ConsoleColor.Yellow, "Returning a default config as a fallback."); } return(result); }
public ChunkyBatchProcessor(ChunkyConfig32bit config) { _config = config; if (!Directory.Exists(config.SourcePath)) { throw new Exception("Attempted to batch operate on a path but it didn't exist"); } Print.Line(ConsoleColor.Cyan, "Starting to process images from: " + config.SourcePath); string[] files = Directory.GetFiles(config.SourcePath); foreach (string filePath in files) { if (filePath.EndsWith(".png") || filePath.EndsWith(".jpg") || filePath.EndsWith(".jpeg") || filePath.EndsWith(".bmp")) { _processors.Enqueue(new ChunkyProcessor(new ChunkyConfig32bit( config.Name, config.TargetDir, filePath, config.TargetImageType, config.TargetPixelFormat, config.RemainderHandlingMode, config.CompatibilityMode, config.GenerateReconstruction, config.GenerateVarianceComparison, config.ChunkWidth, config.ChunkHeight, config.ChunkCountX, config.ChunkCountY, config.MinDepth, config.MaxDepth))); } } }
public ChunkyProcessor(ChunkyConfig32bit config) { string name = config.Name; string targetDir = config.TargetDir; if (string.IsNullOrEmpty(config.SourcePath)) { throw new Exception("Attempted to pass a faulty config (source path missing)"); } if (string.IsNullOrEmpty(config.Name)) { name = Utils.SolveNameFromFileName(config.SourcePath); } if (string.IsNullOrEmpty(config.TargetDir)) { targetDir = Path.Combine(Utils.SolveDirFromFileName(config.SourcePath), "Results"); } _originalBitmap = new Bitmap(config.SourcePath); _originalPixelFormat = _originalBitmap.PixelFormat; _config = new ChunkyConfig32bit( name, targetDir, config.SourcePath, config.TargetImageType ?? Utils.SolveImageExtensionFromFileName(config.SourcePath), config.TargetPixelFormat != default ? config.TargetPixelFormat : _originalPixelFormat, config.RemainderHandlingMode, config.CompatibilityMode, config.GenerateReconstruction, config.GenerateVarianceComparison, config.ChunkWidth, config.ChunkHeight, config.ChunkCountX, config.ChunkCountY, config.MinDepth, config.MaxDepth ); }