-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreverseaa.cpp
72 lines (58 loc) · 2.12 KB
/
reverseaa.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
66
67
68
69
70
71
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "includes/FilterCommon.h"
#include "includes/ReverseAA.h"
extern "C"
{
static unsigned char* ScaledImage = NULL;
const int FilterID = 0x5D13;
const char* FilterName = "ReverseAA";
const char* FilterDescription = "Christoph Feck's ([email protected]) Reverse Anti-Alias filter";
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 b1 = CLR(Input, srcx, srcy, x, y, 0, -2);
auto b = CLR(Input, srcx, srcy, x, y, 0, -1);
auto d = CLR(Input, srcx, srcy, x, y, -1, 0);
auto e = CLR(Input, srcx, srcy, x, y);
auto f = CLR(Input, srcx, srcy, x, y, 1, 0);
auto h = CLR(Input, srcx, srcy, x, y, 0, 1);
auto h5 = CLR(Input, srcx, srcy, x, y, 0, 2);
auto d0 = CLR(Input, srcx, srcy, x, y, -2, 0);
auto f4 = CLR(Input, srcx, srcy, x, y, 2, 0);
int rr, rg, rb, ra = 0;
int gr, gg, gb, ga = 0;
int br, bg, bb, ba = 0;
_ReverseAntiAlias(Red(b1), Red(b), Red(d), Red(e), Red(f), Red(h), Red(h5), Red(d0), Red(f4), &rr, &rg, &rb, &ra);
_ReverseAntiAlias(Green(b1), Green(b), Green(d), Green(e), Green(f), Green(h), Green(h5), Green(d0), Green(f4), &gr, &gg, &gb, &ga);
_ReverseAntiAlias(Blue(b1), Blue(b), Blue(d), Blue(e), Blue(f), Blue(h), Blue(h5), Blue(d0), Blue(f4), &br, &bg, &bb, &ba);
P[1] = RGBINT(_FullClamp(rr), _FullClamp(gr), _FullClamp(br));
P[2] = RGBINT(_FullClamp(rg), _FullClamp(gg), _FullClamp(bg));
P[3] = RGBINT(_FullClamp(rb), _FullClamp(gb), _FullClamp(bb));
P[4] = RGBINT(_FullClamp(ra), _FullClamp(ga), _FullClamp(ba));
for (auto Pixel = 1; Pixel < 5; Pixel++)
{
Write4RGB(ScaledImage, srcx, srcy, x, y, Pixel, P[Pixel]);
}
}
}
}
}
}