Skip to content

Commit

Permalink
Preview Merge is skipped if cutout is the entire image
Browse files Browse the repository at this point in the history
  • Loading branch information
N00MKRAD committed Sep 21, 2020
1 parent ab0115c commit c8fdbf7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Code/Cupscale/PreviewMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,25 @@ static void MergeScrollable ()
Logger.Log("Merging " + outputCutoutPath + " onto " + Program.lastFilename + " using offset " + offsetX + "x" + offsetY);
string scaledPrevPath = Path.Combine(Paths.previewOutPath, "preview-input-scaled.png");
//Image image = MergeOnDisk(scale, scaledPrevPath);
Image image = MergeInMemory(scale, scaledPrevPath);
Image image = MergeInMemory(scale);
MainUIHelper.currentOriginal = IOUtils.GetImage(Paths.tempImgPath);
MainUIHelper.currentOutput = image;
MainUIHelper.currentScale = ImgUtils.GetScale(IOUtils.GetImage(inputCutoutPath), IOUtils.GetImage(outputCutoutPath));
UIHelpers.ReplaceImageAtSameScale(MainUIHelper.previewImg, image);
Program.mainForm.SetProgress(0f, "Done.");
}

public static Image MergeInMemory(int scale, string scaledPrevPath)
public static Image MergeInMemory(int scale)
{
Image sourceImg = IOUtils.GetImage(Paths.tempImgPath);
Image cutout = IOUtils.GetImage(outputCutoutPath);

if (sourceImg.Width * scale == cutout.Width && sourceImg.Height * scale == cutout.Height)
{
Logger.Log("Cutout is the entire image - skipping merge");
return cutout;
}

var destImage = new Bitmap(sourceImg.Width * scale, sourceImg.Height * scale);

using (var graphics = Graphics.FromImage(destImage))
Expand Down

0 comments on commit c8fdbf7

Please sign in to comment.