diff --git a/DyeAtlas.Designer.cs b/DyeAtlas.Designer.cs index 4c1aeeb..0326ea3 100644 --- a/DyeAtlas.Designer.cs +++ b/DyeAtlas.Designer.cs @@ -42,6 +42,8 @@ private void InitializeComponent() this.openfolder = new System.Windows.Forms.Button(); this.gamechoice = new System.Windows.Forms.ComboBox(); this.hsvcompare = new System.Windows.Forms.CheckBox(); + this.batchToImageButton = new System.Windows.Forms.Button(); + this.batchToPNTButton = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.preview)).BeginInit(); this.SuspendLayout(); // @@ -51,9 +53,9 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.preview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.preview.Location = new System.Drawing.Point(12, 168); + this.preview.Location = new System.Drawing.Point(12, 215); this.preview.Name = "preview"; - this.preview.Size = new System.Drawing.Size(450, 381); + this.preview.Size = new System.Drawing.Size(450, 334); this.preview.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.preview.TabIndex = 0; this.preview.TabStop = false; @@ -147,7 +149,7 @@ private void InitializeComponent() // this.currentfile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.currentfile.Location = new System.Drawing.Point(12, 142); + this.currentfile.Location = new System.Drawing.Point(12, 189); this.currentfile.Name = "currentfile"; this.currentfile.ReadOnly = true; this.currentfile.Size = new System.Drawing.Size(450, 20); @@ -156,7 +158,7 @@ private void InitializeComponent() // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 126); + this.label2.Location = new System.Drawing.Point(12, 173); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(63, 13); this.label2.TabIndex = 11; @@ -197,12 +199,34 @@ private void InitializeComponent() this.hsvcompare.UseVisualStyleBackColor = true; this.hsvcompare.CheckedChanged += new System.EventHandler(this.hsvcompare_CheckedChanged); // + // batchToImageButton + // + this.batchToImageButton.Location = new System.Drawing.Point(224, 119); + this.batchToImageButton.Name = "batchToImageButton"; + this.batchToImageButton.Size = new System.Drawing.Size(100, 50); + this.batchToImageButton.TabIndex = 15; + this.batchToImageButton.Text = "Batch .PNT to Image"; + this.batchToImageButton.UseVisualStyleBackColor = true; + this.batchToImageButton.Click += new System.EventHandler(this.batchToImageButton_Click); + // + // batchToPNTButton + // + this.batchToPNTButton.Location = new System.Drawing.Point(118, 119); + this.batchToPNTButton.Name = "batchToPNTButton"; + this.batchToPNTButton.Size = new System.Drawing.Size(100, 50); + this.batchToPNTButton.TabIndex = 16; + this.batchToPNTButton.Text = "Batch Image to .PNT"; + this.batchToPNTButton.UseVisualStyleBackColor = true; + this.batchToPNTButton.Click += new System.EventHandler(this.batchToPNTButton_Click); + // // DyeAtlas // this.AllowDrop = true; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(474, 561); + this.Controls.Add(this.batchToPNTButton); + this.Controls.Add(this.batchToImageButton); this.Controls.Add(this.hsvcompare); this.Controls.Add(this.gamechoice); this.Controls.Add(this.openfolder); @@ -218,7 +242,7 @@ private void InitializeComponent() this.Controls.Add(this.dithering); this.Controls.Add(this.preview); this.Name = "DyeAtlas"; - this.Text = "DyeAtlas - BAH 2022"; + this.Text = "DyeAtlas - BAH 2023"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.DyeAtlas_FormClosed); this.Load += new System.EventHandler(this.DyeAtlas_Load); this.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop); @@ -245,6 +269,8 @@ private void InitializeComponent() private System.Windows.Forms.Button openfolder; private System.Windows.Forms.ComboBox gamechoice; public System.Windows.Forms.CheckBox hsvcompare; + private System.Windows.Forms.Button batchToImageButton; + private System.Windows.Forms.Button batchToPNTButton; } } diff --git a/DyeAtlas.cs b/DyeAtlas.cs index 8d4630e..e4e51db 100644 --- a/DyeAtlas.cs +++ b/DyeAtlas.cs @@ -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 inputFiles = new List(); + 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 inputFiles = new List(); + 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; + } + } } }