-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuper2x.cpp
67 lines (52 loc) · 1.57 KB
/
super2x.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "includes/FilterCommon.h"
#include "includes/Interpolate.h"
extern "C"
{
static unsigned char* ScaledImage = NULL;
const int FilterID = 0x5D15;
const char* FilterName = "Super 2X";
const char* FilterDescription = "FNES' Super 2x Scaling";
bool ComparisonThreshold = false;
const int FilterScaleX = 2;
const int FilterScaleY = 2;
#include "includes/Init.h"
void Apply(int argc, void** argv)
{
if (argc >= 3)
{
auto Input = ((unsigned char*)(argv[0]));
auto srcx = *((int*)(argv[1]));
auto srcy = *((int*)(argv[2]));
Init(srcx, srcy);
int P[5];
for (auto y = 0; y < srcy; y++)
{
for (auto x = 0; x < srcx; x++)
{
auto n = CLR(Input, srcx, srcy, x, y, 0, -1);
auto w = CLR(Input, srcx, srcy, x, y, -1, 0);
auto c = CLR(Input, srcx, srcy, x, y, 0, 0);
auto e = CLR(Input, srcx, srcy, x, y, 1, 0);
auto s = CLR(Input, srcx, srcy, x, y, 0, 1);
auto wx = w;
auto ex = e;
auto cw = _Mixpal(c, w);
auto ce = _Mixpal(c, e);
P[1] = (((IsLike(w, n)) && (IsNotLike(n, e)) && (IsNotLike(w, s))) ? wx : cw);
P[2] = (((IsLike(n, e)) && (IsNotLike(n, w)) && (IsNotLike(e, s))) ? ex : ce);
P[3] = (((IsLike(w, s)) && (IsNotLike(w, n)) && (IsNotLike(s, e))) ? wx : cw);
P[4] = (((IsLike(s, e)) && (IsNotLike(w, s)) && (IsNotLike(n, e))) ? ex : ce);
for (auto Pixel = 1; Pixel < 5; Pixel++)
{
Write4RGB(ScaledImage, srcx, srcy, x, y, Pixel, P[Pixel]);
}
}
}
}
}
}