diff --git a/Code/ClipboardPreview.cs b/Code/ClipboardPreview.cs
index 22d10e7..203fc33 100644
--- a/Code/ClipboardPreview.cs
+++ b/Code/ClipboardPreview.cs
@@ -1,4 +1,6 @@
-using System;
+using ImageMagick;
+using SixLabors.ImageSharp.Processing.Processors.Quantization;
+using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
@@ -16,7 +18,7 @@ class ClipboardPreview
public static Bitmap originalPreview;
public static Bitmap resultPreview;
- public static void CopyToClipboardSideBySide(bool fullImage = false)
+ public static async void CopyToClipboardSideBySide(bool saveToFile, bool fullImage = false)
{
//if (resultPreview == null)
//return;
@@ -101,10 +103,22 @@ public static void CopyToClipboardSideBySide(bool fullImage = false)
}
try
{
- Clipboard.SetDataObject(outputImage);
+ if (saveToFile)
+ {
+ string comparisonSavePath = Path.ChangeExtension(Program.lastFilename, null) + "-comparison.png";
+ outputImage.Save(comparisonSavePath);
+ await ImageProcessing.ConvertImage(comparisonSavePath, ImageProcessing.Format.PngFast, false, false);
+ MessageBox.Show("Saved current comparison to:\n\n" + comparisonSavePath, "Message");
+ }
+ else
+ {
+ Clipboard.SetDataObject(outputImage);
+ }
}
catch
- { }
+ {
+ MessageBox.Show("Failed to save comparison.", "Error");
+ }
}
public static void CopyToClipboardSlider(bool fullImage = false)
diff --git a/Code/Cupscale.csproj b/Code/Cupscale.csproj
index f8f2222..cdd9648 100644
--- a/Code/Cupscale.csproj
+++ b/Code/Cupscale.csproj
@@ -23,6 +23,7 @@
+
diff --git a/Code/Cupscale/MainForm.Designer.cs b/Code/Cupscale/MainForm.Designer.cs
index cf98dd4..031de4c 100644
--- a/Code/Cupscale/MainForm.Designer.cs
+++ b/Code/Cupscale/MainForm.Designer.cs
@@ -112,6 +112,7 @@ private void InitializeComponent()
this.panel7 = new System.Windows.Forms.Panel();
this.settingsBtn = new HTAlt.WinForms.HTButton();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
+ this.savePreviewToFileBtn = new HTAlt.WinForms.HTButton();
this.tableLayoutPanel1.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
this.panel5.SuspendLayout();
@@ -485,6 +486,7 @@ private void InitializeComponent()
//
this.previewGroupbox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
+ this.previewGroupbox.Controls.Add(this.savePreviewToFileBtn);
this.previewGroupbox.Controls.Add(this.copyCompToClipboardBtn);
this.previewGroupbox.Controls.Add(this.label12);
this.previewGroupbox.Controls.Add(this.prevClipboardTypeCombox);
@@ -506,9 +508,9 @@ private void InitializeComponent()
this.copyCompToClipboardBtn.ForeColor = System.Drawing.Color.White;
this.copyCompToClipboardBtn.Location = new System.Drawing.Point(6, 56);
this.copyCompToClipboardBtn.Name = "copyCompToClipboardBtn";
- this.copyCompToClipboardBtn.Size = new System.Drawing.Size(318, 30);
+ this.copyCompToClipboardBtn.Size = new System.Drawing.Size(156, 30);
this.copyCompToClipboardBtn.TabIndex = 12;
- this.copyCompToClipboardBtn.Text = "Copy Comparison To Clipboard";
+ this.copyCompToClipboardBtn.Text = "Copy To Clipboard";
this.copyCompToClipboardBtn.UseVisualStyleBackColor = false;
this.copyCompToClipboardBtn.Click += new System.EventHandler(this.copyCompToClipboardBtn_Click);
//
@@ -988,6 +990,22 @@ private void InitializeComponent()
this.settingsBtn.UseVisualStyleBackColor = false;
this.settingsBtn.Click += new System.EventHandler(this.settingsBtn_Click);
//
+ // savePreviewToFileBtn
+ //
+ this.savePreviewToFileBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.savePreviewToFileBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
+ this.savePreviewToFileBtn.FlatAppearance.BorderSize = 0;
+ this.savePreviewToFileBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.savePreviewToFileBtn.ForeColor = System.Drawing.Color.White;
+ this.savePreviewToFileBtn.Location = new System.Drawing.Point(168, 56);
+ this.savePreviewToFileBtn.Name = "savePreviewToFileBtn";
+ this.savePreviewToFileBtn.Size = new System.Drawing.Size(156, 30);
+ this.savePreviewToFileBtn.TabIndex = 13;
+ this.savePreviewToFileBtn.Text = "Save To File";
+ this.savePreviewToFileBtn.UseVisualStyleBackColor = false;
+ this.savePreviewToFileBtn.Click += new System.EventHandler(this.savePreviewToFileBtn_Click);
+ //
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -1064,5 +1082,6 @@ private void InitializeComponent()
private HTAlt.WinForms.HTButton settingsBtn;
private Button model1TreeBtn;
private Button model2TreeBtn;
+ private HTAlt.WinForms.HTButton savePreviewToFileBtn;
}
}
diff --git a/Code/Cupscale/MainForm.cs b/Code/Cupscale/MainForm.cs
index 7d7a835..da68a94 100644
--- a/Code/Cupscale/MainForm.cs
+++ b/Code/Cupscale/MainForm.cs
@@ -212,7 +212,7 @@ async Task DragNDrop (string [] array)
File.Copy(path, Paths.tempImgPath, true);
//await Upscale.Preprocessing(Paths.tempImgPath.GetParentDir());
bool fillAlpha = !bool.Parse(Config.Get("alpha"));
- await UpscaleProcessing.ConvertImageTo(path, Paths.tempImgPath, UpscaleProcessing.Format.PngFast, fillAlpha, false, false);
+ await ImageProcessing.ConvertImageTo(path, Paths.tempImgPath, ImageProcessing.Format.PngFast, fillAlpha, false, false);
Logger.Log("Done Preprocessing");
previewImg.Image = IOUtils.GetImage(Paths.tempImgPath);
Program.lastFilename = path;
@@ -248,8 +248,8 @@ private void refreshPreviewCutoutBtn_Click(object sender, EventArgs e)
private void copyCompToClipboardBtn_Click(object sender, EventArgs e)
{
- if (prevClipboardTypeCombox.SelectedIndex == 0) ClipboardPreview.CopyToClipboardSideBySide();
- if (prevClipboardTypeCombox.SelectedIndex == 1) ClipboardPreview.CopyToClipboardSlider();
+ if (prevClipboardTypeCombox.SelectedIndex == 0) ClipboardPreview.CopyToClipboardSideBySide(false);
+ if (prevClipboardTypeCombox.SelectedIndex == 1) ClipboardPreview.CopyToClipboardSlider(false);
}
private void model1TreeBtn_Click(object sender, EventArgs e)
@@ -261,5 +261,11 @@ private void model2TreeBtn_Click(object sender, EventArgs e)
{
ModelSelectForm treeForm = new ModelSelectForm(model2TreeBtn, 2);
}
+
+ private void savePreviewToFileBtn_Click(object sender, EventArgs e)
+ {
+ if (prevClipboardTypeCombox.SelectedIndex == 0) ClipboardPreview.CopyToClipboardSideBySide(true);
+ if (prevClipboardTypeCombox.SelectedIndex == 1) ClipboardPreview.CopyToClipboardSlider(true);
+ }
}
}
diff --git a/Code/Cupscale/Upscale.cs b/Code/Cupscale/Upscale.cs
index 9adf5b9..6278d47 100644
--- a/Code/Cupscale/Upscale.cs
+++ b/Code/Cupscale/Upscale.cs
@@ -73,7 +73,7 @@ public static async Task Preprocessing (string path, bool appendExt = false)
{
Logger.Log("Preprocessing: " + path);
bool fillAlpha = !bool.Parse(Config.Get("alpha"));
- await UpscaleProcessing.ConvertImages(path, UpscaleProcessing.Format.PngFast, fillAlpha);
+ await ImageProcessing.ConvertImages(path, ImageProcessing.Format.PngFast, fillAlpha);
}
public static async Task Postprocessing()
@@ -82,17 +82,17 @@ public static async Task Postprocessing()
await Program.PutTaskDelay();
Logger.Log("Postprocessing - outputFormat.SelectedIndex = " + outputFormat.SelectedIndex);
if (outputFormat.SelectedIndex == 0)
- UpscaleProcessing.ChangeOutputExtensions("png");
+ ImageProcessing.ChangeOutputExtensions("png");
if (outputFormat.SelectedIndex == 1)
- await UpscaleProcessing.ConvertImagesToOriginalFormat();
+ await ImageProcessing.ConvertImagesToOriginalFormat();
if (outputFormat.SelectedIndex == 2)
- await UpscaleProcessing.ConvertImages(Paths.imgOutPath, UpscaleProcessing.Format.JpegHigh);
+ await ImageProcessing.ConvertImages(Paths.imgOutPath, ImageProcessing.Format.JpegHigh);
if (outputFormat.SelectedIndex == 3)
- await UpscaleProcessing.ConvertImages(Paths.imgOutPath, UpscaleProcessing.Format.JpegMed);
+ await ImageProcessing.ConvertImages(Paths.imgOutPath, ImageProcessing.Format.JpegMed);
if (outputFormat.SelectedIndex == 4)
- await UpscaleProcessing.ConvertImages(Paths.imgOutPath, UpscaleProcessing.Format.WeppyHigh);
+ await ImageProcessing.ConvertImages(Paths.imgOutPath, ImageProcessing.Format.WeppyHigh);
if (outputFormat.SelectedIndex == 5)
- await UpscaleProcessing.ConvertImages(Paths.imgOutPath, UpscaleProcessing.Format.WeppyLow);
+ await ImageProcessing.ConvertImages(Paths.imgOutPath, ImageProcessing.Format.WeppyLow);
}
public static async Task FilenamePostprocessing ()
diff --git a/Code/Forms/ModelSelectForm.Designer.cs b/Code/Forms/ModelSelectForm.Designer.cs
index bfd4d8f..f57e5c6 100644
--- a/Code/Forms/ModelSelectForm.Designer.cs
+++ b/Code/Forms/ModelSelectForm.Designer.cs
@@ -42,9 +42,10 @@ private void InitializeComponent()
this.modelTree.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.modelTree.Dock = System.Windows.Forms.DockStyle.Fill;
this.modelTree.ForeColor = System.Drawing.Color.White;
- this.modelTree.Location = new System.Drawing.Point(3, 3);
+ this.modelTree.Location = new System.Drawing.Point(6, 6);
+ this.modelTree.Margin = new System.Windows.Forms.Padding(6);
this.modelTree.Name = "modelTree";
- this.modelTree.Size = new System.Drawing.Size(714, 664);
+ this.modelTree.Size = new System.Drawing.Size(708, 658);
this.modelTree.TabIndex = 0;
this.modelTree.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.modelTree_AfterSelect);
//
diff --git a/Code/Forms/ModelSelectForm.cs b/Code/Forms/ModelSelectForm.cs
index 4ecb949..dfde1d1 100644
--- a/Code/Forms/ModelSelectForm.cs
+++ b/Code/Forms/ModelSelectForm.cs
@@ -26,6 +26,7 @@ public ModelSelectForm(Button modelButton, int modelNumber)
CenterToScreen();
modelBtn = modelButton;
modelNo = modelNumber;
+ SelectLastUsed();
}
private void ModelSelectForm_Load(object sender, EventArgs e)
@@ -33,7 +34,26 @@ private void ModelSelectForm_Load(object sender, EventArgs e)
DirectoryInfo modelsDir = new DirectoryInfo(Config.Get("modelPath"));
BuildTree(modelsDir, modelTree.Nodes);
modelTree.ExpandAll();
- modelTree.SelectedNode = modelTree.Nodes[0];
+ }
+
+ private void SelectLastUsed()
+ {
+ if(string.IsNullOrWhiteSpace(Program.currentModel1))
+ modelTree.SelectedNode = modelTree.Nodes[0];
+ else
+ CheckNodesRecursive(modelTree.Nodes[0]);
+ }
+
+ private void CheckNodesRecursive(TreeNode parentNode)
+ {
+ Logger.Log("Checking if " + parentNode.Text.Trim() + " == " + modelBtn.Text.Trim());
+ if (parentNode.Text.Trim() == modelBtn.Text.Trim())
+ modelTree.SelectedNode = parentNode;
+
+ foreach (TreeNode oSubNode in parentNode.Nodes)
+ {
+ CheckNodesRecursive(oSubNode);
+ }
}
private void BuildTree(DirectoryInfo directoryInfo, TreeNodeCollection addInMe)
diff --git a/Code/ImageUtils/UpscaleProcessing.cs b/Code/ImageUtils/ImageProcessing.cs
similarity index 98%
rename from Code/ImageUtils/UpscaleProcessing.cs
rename to Code/ImageUtils/ImageProcessing.cs
index 9e9915d..da76ca5 100644
--- a/Code/ImageUtils/UpscaleProcessing.cs
+++ b/Code/ImageUtils/ImageProcessing.cs
@@ -1,14 +1,17 @@
using System;
+using System.Drawing;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
using Cupscale.IO;
using ImageMagick;
+using SixLabors.ImageSharp;
+using SixLabors.ImageSharp.Formats.Png;
using Paths = Cupscale.IO.Paths;
namespace Cupscale
{
- internal class UpscaleProcessing
+ internal class ImageProcessing
{
public enum Format
{
diff --git a/Code/UI/MainUIHelper.cs b/Code/UI/MainUIHelper.cs
index e76846a..a282534 100644
--- a/Code/UI/MainUIHelper.cs
+++ b/Code/UI/MainUIHelper.cs
@@ -55,7 +55,7 @@ public static async void UpscaleImage()
Cancel("I/O Error");
return;
}
- await UpscaleProcessing.ConvertImages(Paths.imgInPath, UpscaleProcessing.Format.PngFast, !Config.GetBool("alpha"), true, true);
+ await ImageProcessing.ConvertImages(Paths.imgInPath, ImageProcessing.Format.PngFast, !Config.GetBool("alpha"), true, true);
ModelData mdl = Upscale.GetModelData();
await ESRGAN.UpscaleBasic(Paths.imgInPath, Paths.imgOutPath, mdl, Config.Get("tilesize"), bool.Parse(Config.Get("alpha")), ESRGAN.PreviewMode.None);
await Upscale.Postprocessing();