Skip to content

Commit

Permalink
All fixed. Ready up.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekStoj91 committed May 21, 2023
1 parent 6faf219 commit 7054e87
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 43 deletions.
6 changes: 3 additions & 3 deletions Algorithm/HqxFamily/Hqx2x.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void Hqx2xMeth(Frame src, out Frame dst, double eqDiff, bool wrapX
uint Xres, Yres;
Xres = (uint)src.Width;
Yres = (uint)src.Height;
dst = new Frame(Xres * 2, Yres * 2, src.OffsetY, src.OffsetY);
dst = new Frame(2 * Xres, 2 * Yres, 2 * src.OffsetY, 2 * src.OffsetY);
uint spIdx = 0, dpIdx = 0;
//Don't shift trA, as it uses shift right instead of a mask for comparisons.
uint dpL = Xres * 2;
Expand Down Expand Up @@ -5510,7 +5510,7 @@ public override void Process(Frame src, out Frame dst, double eqDiff, bool scale
Hqx2xMeth(src, out dst, eqDiff);
if (!scale)
{
dst = new Frame(new Bitmap(src.ToBitmap(), (int)src.Width, (int)src.Height), src.OffsetX, src.OffsetY);
dst = new Frame(new Bitmap(dst.ToBitmap(), (int)src.Width, (int)src.Height), src.OffsetX, src.OffsetY);
}
}

Expand All @@ -5519,7 +5519,7 @@ public override void Process(Bitmap src, out Bitmap dst, double eqDiff, bool sca
Hqx2xMeth(src, out dst, eqDiff);
if (!scale)
{
dst = new Bitmap(src, (int)src.Width, (int)src.Height);
dst = new Bitmap(dst, (int)src.Width, (int)src.Height);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Algorithm/HqxFamily/Hqx3x.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static void Hqx3xMeth(
uint Xres, Yres;
Xres = (uint)src.Width;
Yres = (uint)src.Height;
dst = new Frame(Xres * 3, Yres * 3, src.OffsetY, src.OffsetY);
dst = new Frame(3 * Xres, 3 * Yres, 3 * src.OffsetY, 3 * src.OffsetY);
uint spIdx = 0, dpIdx = 0;
uint dpL = Xres * 3;

Expand Down Expand Up @@ -7458,7 +7458,7 @@ public override void Process(Frame src, out Frame dst, double eqDiff, bool scale
Hqx3xMeth(src, out dst, eqDiff);
if (!scale)
{
dst = new Frame(new Bitmap(src.ToBitmap(), (int)src.Width, (int)src.Height), src.OffsetX, src.OffsetY);
dst = new Frame(new Bitmap(dst.ToBitmap(), (int)src.Width, (int)src.Height), src.OffsetX, src.OffsetY);
}
}

Expand All @@ -7467,7 +7467,7 @@ public override void Process(Bitmap src, out Bitmap dst, double eqDiff, bool sca
Hqx3xMeth(src, out dst, eqDiff);
if (!scale)
{
dst = new Bitmap(src, (int)src.Width, (int)src.Height);
dst = new Bitmap(dst, (int)src.Width, (int)src.Height);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Algorithm/HqxFamily/Hqx4x.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void Hqx4xMeth(
uint Xres, Yres;
Xres = (uint)src.Width;
Yres = (uint)src.Height;
dst = new Frame(Xres * 4, Yres * 4, src.OffsetY, src.OffsetY);
dst = new Frame(4 * Xres, 4 * Yres, 4 * src.OffsetY, 4 * src.OffsetY);
uint spIdx = 0, dpIdx = 0;
//Don't shift trA, as it uses shift right instead of a mask for comparisons.
//trY <<= 2 * 8;
Expand Down Expand Up @@ -9372,7 +9372,7 @@ public override void Process(Frame src, out Frame dst, double eqDiff, bool scale
Hqx4xMeth(src, out dst, eqDiff);
if (!scale)
{
dst = new Frame(new Bitmap(src.ToBitmap(), (int)src.Width, (int)src.Height), src.OffsetX, src.OffsetY);
dst = new Frame(new Bitmap(dst.ToBitmap(), (int)src.Width, (int)src.Height), src.OffsetX, src.OffsetY);
}
}

Expand All @@ -9381,7 +9381,7 @@ public override void Process(Bitmap src, out Bitmap dst, double eqDiff, bool sca
Hqx4xMeth(src, out dst, eqDiff);
if (!scale)
{
dst = new Bitmap(src, (int)src.Width, (int)src.Height);
dst = new Bitmap(dst, (int)src.Width, (int)src.Height);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Algorithm/ScalexFamily/Scalex2x.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public static void Scalex2xMeth(Frame src, out Frame dst, double eqDiff)
w *= 2;
h *= 2;

dst = new Frame(w, h, src.OffsetX, src.OffsetY);
dst = new Frame(w, h, 2 * src.OffsetX, 2 * src.OffsetY);

uint px, py;

Expand All @@ -298,7 +298,7 @@ public override void Process(Frame src, out Frame dst, double eqDiff, bool scale
Scalex2xMeth(src, out dst, eqDiff);
if (!scale)
{
dst = new Frame(new Bitmap(src.ToBitmap(), (int)src.Width, (int)src.Height), src.OffsetX, src.OffsetY);
dst = new Frame(new Bitmap(dst.ToBitmap(), (int)src.Width, (int)src.Height), src.OffsetX, src.OffsetY);
}
}

Expand All @@ -307,7 +307,7 @@ public override void Process(Bitmap src, out Bitmap dst, double eqDiff, bool sca
Scalex2xMeth(src, out dst, eqDiff);
if (!scale)
{
dst = new Bitmap(src, (int)src.Width, (int)src.Height);
dst = new Bitmap(dst, (int)src.Width, (int)src.Height);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Algorithm/ScalexFamily/Scalex3x.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public static void Scalex3xMeth(Frame src, out Frame dst, double eqDiff)
w *= 3;
h *= 3;

dst = new Frame(w, h, src.OffsetX, src.OffsetY);
dst = new Frame(w, h, 3 * src.OffsetX, 3 * src.OffsetY);

uint px, py;

Expand Down Expand Up @@ -500,7 +500,7 @@ public override void Process(Frame src, out Frame dst, double eqDiff, bool scale
Scalex3xMeth(src, out dst, eqDiff);
if (!scale)
{
dst = new Frame(new Bitmap(src.ToBitmap(), (int)src.Width, (int)src.Height), src.OffsetX, src.OffsetY);
dst = new Frame(new Bitmap(dst.ToBitmap(), (int)src.Width, (int)src.Height), src.OffsetX, src.OffsetY);
}
}

Expand All @@ -509,7 +509,7 @@ public override void Process(Bitmap src, out Bitmap dst, double eqDiff, bool sca
Scalex3xMeth(src, out dst, eqDiff);
if (!scale)
{
dst = new Bitmap(src, (int)src.Width, (int)src.Height);
dst = new Bitmap(dst, (int)src.Width, (int)src.Height);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Algorithm/ScalexFamily/Scalex4x.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override void Process(Frame src, out Frame dst, double eqDiff, bool scale
Scalex4xMeth(src, out dst, eqDiff);
if (!scale)
{
dst = new Frame(new Bitmap(src.ToBitmap(), (int)src.Width, (int)src.Height), src.OffsetX, src.OffsetY);
dst = new Frame(new Bitmap(dst.ToBitmap(), (int)src.Width, (int)src.Height), src.OffsetX, src.OffsetY);
}
}

Expand All @@ -52,7 +52,7 @@ public override void Process(Bitmap src, out Bitmap dst, double eqDiff, bool sca
Scalex4xMeth(src, out dst, eqDiff);
if (!scale)
{
dst = new Bitmap(src, (int)src.Width, (int)src.Height);
dst = new Bitmap(dst, (int)src.Width, (int)src.Height);
}
}
}
Expand Down
48 changes: 23 additions & 25 deletions FOnlineScalex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,33 +179,31 @@ public void DoWork(string inDir, string outDir, bool recursive, double eqDiff,
Bitmap inPic = (Bitmap)Bitmap.FromFile(srcFile);
Bitmap? outPic = null;

if (scale)
IAlgorithm algorithm;
switch (algorithmId)
{
IAlgorithm algorithm;
switch (algorithmId)
{
case IAlgorithm.AlgorithmId.Scalex2x:
default:
algorithm = new Scalex2x();
break;
case IAlgorithm.AlgorithmId.Scalex3x:
algorithm = new Scalex3x();
break;
case IAlgorithm.AlgorithmId.Scalex4x:
algorithm = new Scalex3x();
break;
case IAlgorithm.AlgorithmId.Hqx2x:
algorithm = new Hqx2x();
break;
case IAlgorithm.AlgorithmId.Hqx3x:
algorithm = new Hqx3x();
break;
case IAlgorithm.AlgorithmId.Hqx4x:
algorithm = new Hqx4x();
break;
}
algorithm.Process(inPic, out outPic, eqDiff, scale);
case IAlgorithm.AlgorithmId.Scalex2x:
default:
algorithm = new Scalex2x();
break;
case IAlgorithm.AlgorithmId.Scalex3x:
algorithm = new Scalex3x();
break;
case IAlgorithm.AlgorithmId.Scalex4x:
algorithm = new Scalex3x();
break;
case IAlgorithm.AlgorithmId.Hqx2x:
algorithm = new Hqx2x();
break;
case IAlgorithm.AlgorithmId.Hqx3x:
algorithm = new Hqx3x();
break;
case IAlgorithm.AlgorithmId.Hqx4x:
algorithm = new Hqx4x();
break;
}
algorithm.Process(inPic, out outPic, eqDiff, scale);

string extension = Path.GetExtension(srcFile).ToLower();
if (recursive)
{
Expand Down
1 change: 1 addition & 0 deletions MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,25 @@ private void GeneratePreview()
}

algorithm?.Process(srcBitmap, out dstBitmap, 1.0 - this.eqAccuracy, cboxScale.Checked);
pboxPreview.Image = dstBitmap;

if (this.cboxPostProc.Checked)
{
if (dstBitmap != null)
{
Bitmap postDstBitmap;
PostProcessing.PostProcessor.Process(dstBitmap, out postDstBitmap);
pboxPreview.Image = postDstBitmap;
}
else
{
pboxPreview.Image = dstBitmap;
}
}
else
{
pboxPreview.Image = dstBitmap;
}

}

private void cboxAlgo_SelectedIndexChanged(object sender, EventArgs e)
Expand All @@ -356,5 +374,10 @@ private void cboxScale_CheckedChanged(object sender, EventArgs e)
{
GeneratePreview();
}

private void cboxPostProc_CheckedChanged(object sender, EventArgs e)
{
GeneratePreview();
}
}
}
Binary file modified Misc/Demo1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Misc/Demo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7054e87

Please sign in to comment.