diff --git a/Code/Cupscale/MainForm.cs b/Code/Cupscale/MainForm.cs index b7a985b..030f2b1 100644 --- a/Code/Cupscale/MainForm.cs +++ b/Code/Cupscale/MainForm.cs @@ -178,11 +178,15 @@ private void prevToggleFilterBtn_Click(object sender, EventArgs e) if (previewImg.InterpolationMode != InterpolationMode.NearestNeighbor) { previewImg.InterpolationMode = InterpolationMode.NearestNeighbor; - } + prevToggleFilterBtn.Text = "Switch To Bicubic Filtering"; + Program.currentFilter = ImageMagick.FilterType.Point; + } else { previewImg.InterpolationMode = InterpolationMode.HighQualityBicubic; - } + prevToggleFilterBtn.Text = "Switch To Point Filtering"; + Program.currentFilter = ImageMagick.FilterType.Catrom; + } } private void modelTabControl_PageChanged(object sender, PageChangedEventArgs e) @@ -658,7 +662,7 @@ private void InitializeComponent() this.prevToggleFilterBtn.Name = "prevToggleFilterBtn"; this.prevToggleFilterBtn.Size = new System.Drawing.Size(330, 30); this.prevToggleFilterBtn.TabIndex = 4; - this.prevToggleFilterBtn.Text = "Toggle Filtering Mode (Bilinear/Nearest)"; + this.prevToggleFilterBtn.Text = "Switch To Bicubic Filtering"; this.prevToggleFilterBtn.UseVisualStyleBackColor = false; this.prevToggleFilterBtn.Click += new System.EventHandler(this.prevToggleFilterBtn_Click); // diff --git a/Code/Cupscale/PreviewMerger.cs b/Code/Cupscale/PreviewMerger.cs index d2b7e77..244a9d4 100644 --- a/Code/Cupscale/PreviewMerger.cs +++ b/Code/Cupscale/PreviewMerger.cs @@ -36,17 +36,17 @@ public static void Merge() offsetX *= num; offsetY *= num; Logger.Log("Merging " + outputCutoutPath + " onto " + Program.lastFilename + " using offset " + offsetX + "x" + offsetY); - MagickImage val = new MagickImage(Program.lastFilename); - MagickImage val2 = new MagickImage(outputCutoutPath); - val.FilterType = (FilterType)1; - val.Scale(new Percentage(num * 100)); + MagickImage sourceImg = new MagickImage(Program.lastFilename); + MagickImage cutout = new MagickImage(outputCutoutPath); + sourceImg.FilterType = Program.currentFilter; + sourceImg.Scale(new Percentage(num * 100)); string scaledPrevPath = Path.Combine(Paths.previewOutPath, "preview-input-scaled.png"); - val.Format = (MagickFormat)171; - val.Quality = (10); - val.Write(scaledPrevPath); - val.Composite((IMagickImage)(object)val2, (Gravity)1, new PointD((double)offsetX, (double)offsetY)); + sourceImg.Format = MagickFormat.Jpg; + sourceImg.Quality = 98; + sourceImg.Write(scaledPrevPath); + sourceImg.Composite(cutout, (Gravity)1, new PointD(offsetX, offsetY)); string text2 = Path.Combine(Paths.previewOutPath, "preview-merged.png"); - val.Write(text2); + sourceImg.Write(text2); Image image = IOUtils.GetImage(text2); PreviewTabHelper.currentOriginal = IOUtils.GetImage(scaledPrevPath); PreviewTabHelper.currentOutput = image; diff --git a/Code/Cupscale/Program.cs b/Code/Cupscale/Program.cs index 3568683..97f0763 100644 --- a/Code/Cupscale/Program.cs +++ b/Code/Cupscale/Program.cs @@ -3,6 +3,7 @@ using System.Windows.Forms; using Cupscale.Forms; using Cupscale.IO; +using ImageMagick; namespace Cupscale { @@ -11,6 +12,7 @@ internal static class Program public static MainForm mainForm; public static string lastFilename; public static string lastModelName; + public static FilterType currentFilter = FilterType.Point; [STAThread] private static void Main()