Skip to content

Commit

Permalink
Improved filter toggle button, merged preview now uses active filter …
Browse files Browse the repository at this point in the history
…type
  • Loading branch information
N00MKRAD committed Sep 12, 2020
1 parent af5a370 commit 5858cb6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
10 changes: 7 additions & 3 deletions Code/Cupscale/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
//
Expand Down
18 changes: 9 additions & 9 deletions Code/Cupscale/PreviewMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ushort>)(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;
Expand Down
2 changes: 2 additions & 0 deletions Code/Cupscale/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Windows.Forms;
using Cupscale.Forms;
using Cupscale.IO;
using ImageMagick;

namespace Cupscale
{
Expand All @@ -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()
Expand Down

0 comments on commit 5858cb6

Please sign in to comment.