-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxbrz.cpp
52 lines (40 loc) · 1.16 KB
/
xbrz.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
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "includes/FilterCommon.h"
#include "includes/xbrz.h"
extern "C"
{
static unsigned char* ScaledImage = NULL;
const int FilterID = 0x5D03;
const char* FilterName = "XBRZ";
const char* FilterDescription = "XBRZnX family of filters";
bool ComparisonThreshold = false;
int FilterScaleX = 2;
int FilterScaleY = 2;
#include "includes/Init.h"
void Apply(int argc, void** argv)
{
if (argc >= 4)
{
auto Input = ((unsigned char*)(argv[0]));
auto srcx = *((int*)(argv[1]));
auto srcy = *((int*)(argv[2]));
auto scale = *((int*)(argv[3]));
scale = scale < 2 ? 2 : scale;
scale = scale > 6 ? 6 : scale;
FilterScaleX = scale;
FilterScaleY = scale;
Init(srcx, srcy);
auto src = (uint32_t*)malloc(srcx * srcy * sizeof(uint32_t));
auto dst = (uint32_t*)malloc(SizeX() * SizeY() * sizeof(uint32_t));
xbrz::Copy(src, Input, srcx, srcy);
xbrz::scale(scale, src, dst, srcx, srcy, xbrz::ColorFormat::ARGB, xbrz::ScalerCfg(), 0, srcy);
xbrz::Copy(ScaledImage, dst, SizeX(), SizeY());
free(dst);
free(src);
}
}
}