Skip to content

Commit

Permalink
+adding batch processing buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
bahstrike committed Jul 30, 2023
1 parent 3b21df3 commit 160d1c6
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 5 deletions.
36 changes: 31 additions & 5 deletions DyeAtlas.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

118 changes: 118 additions & 0 deletions DyeAtlas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,5 +489,123 @@ public static double distance(double alpha, double beta)
}
}
#endregion

private void batchToImageButton_Click(object sender, EventArgs e)
{
FolderBrowserDialog folderIn = new FolderBrowserDialog();

folderIn.Description = "Input: select a folder containing .PNT files";
if (Directory.Exists(MyPaintingsPath))
folderIn.SelectedPath = MyPaintingsPath;
folderIn.ShowNewFolderButton = false;

if (folderIn.ShowDialog() != DialogResult.OK)
return;

if (!Directory.Exists(folderIn.SelectedPath))
return;


List<string> inputFiles = new List<string>();
inputFiles.AddRange(Directory.GetFiles(folderIn.SelectedPath, "*.pnt"));

if(inputFiles.Count == 0)
{
MessageBox.Show("No .PNT files found in this directory!");
return;
}



FolderBrowserDialog folderOut = new FolderBrowserDialog();

folderOut.Description = "Output: select a folder to store images";
folderOut.ShowNewFolderButton = true;

if (folderOut.ShowDialog() != DialogResult.OK)
return;

try
{
Cursor.Current = Cursors.WaitCursor;
Enabled = false;

foreach (string inFile in inputFiles)
{
string outFile = Path.Combine(folderOut.SelectedPath, Path.GetFileNameWithoutExtension(inFile) + ".png");

OpenFile(inFile);
Application.DoEvents();
SaveFile(outFile);
}
}
finally
{
Cursor.Current = Cursors.Default;
Enabled = true;
}
}

private void batchToPNTButton_Click(object sender, EventArgs e)
{
FolderBrowserDialog folderIn = new FolderBrowserDialog();

folderIn.Description = "Input: select a folder containing image files";
folderIn.ShowNewFolderButton = false;

if (folderIn.ShowDialog() != DialogResult.OK)
return;

if (!Directory.Exists(folderIn.SelectedPath))
return;


List<string> inputFiles = new List<string>();
inputFiles.AddRange(Directory.GetFiles(folderIn.SelectedPath, "*.jpg"));
inputFiles.AddRange(Directory.GetFiles(folderIn.SelectedPath, "*.jpeg"));
inputFiles.AddRange(Directory.GetFiles(folderIn.SelectedPath, "*.bmp"));
inputFiles.AddRange(Directory.GetFiles(folderIn.SelectedPath, "*.png"));
inputFiles.AddRange(Directory.GetFiles(folderIn.SelectedPath, "*.gif"));
inputFiles.AddRange(Directory.GetFiles(folderIn.SelectedPath, "*.tga"));
inputFiles.AddRange(Directory.GetFiles(folderIn.SelectedPath, "*.tiff"));

if (inputFiles.Count == 0)
{
MessageBox.Show("No image files found in this directory!");
return;
}



FolderBrowserDialog folderOut = new FolderBrowserDialog();

folderOut.Description = "Output: select a folder to store .PNT files";
if (Directory.Exists(MyPaintingsPath))
folderOut.SelectedPath = MyPaintingsPath;
folderOut.ShowNewFolderButton = true;

if (folderOut.ShowDialog() != DialogResult.OK)
return;

try
{
Cursor.Current = Cursors.WaitCursor;
Enabled = false;

foreach (string inFile in inputFiles)
{
string outFile = Path.Combine(folderOut.SelectedPath, Path.GetFileNameWithoutExtension(inFile) + ".pnt");

OpenFile(inFile);
Application.DoEvents();
SaveFile(outFile);
}
}
finally
{
Cursor.Current = Cursors.Default;
Enabled = true;
}
}
}
}

0 comments on commit 160d1c6

Please sign in to comment.