-
-
Notifications
You must be signed in to change notification settings - Fork 65
/
qluminor.cpp
43 lines (33 loc) · 1.35 KB
/
qluminor.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
#include <vector>
#include "qluminor.h"
#include "luminor.h"
#include "luminor_rgba.h"
#include "HalideBuffer.h"
using namespace Halide::Runtime;
QLuminor::QLuminor(QObject *parent) : QObject(parent)
{
}
QImage QLuminor::toLuminor(const QImage &src, float brightness, float contrast, float gamma)
{
if(src.format() == QImage::Format_ARGB32 || src.format() == QImage::Format_RGBA8888)
return toLuminorRGBA(src, brightness, contrast, gamma);
std::vector<int> sizes(3);
sizes[0] = src.width();
sizes[1] = src.height();
sizes[2] = src.depth()/8;
Buffer<uint8_t> input(const_cast<uint8_t*>(src.bits()), sizes);
QImage dest(src.size(),src.format());
Buffer<uint8_t> output(const_cast<uint8_t*>(dest.bits()), sizes);
int result = 0;
result = luminor(input, brightness, contrast, gamma, output);
return dest;
}
QImage QLuminor::toLuminorRGBA(const QImage &src, float brightness, float contrast, float gamma)
{
QImage dest(src.size(),src.format());
auto input = Buffer<uint8_t>::make_interleaved(const_cast<uint8_t*>(src.bits()), src.width(), src.height(), src.depth()/8);
auto output = Buffer<uint8_t>::make_interleaved(const_cast<uint8_t*>(dest.bits()), dest.width(), dest.height(), dest.depth()/8);
int result = 0;
result = luminor_rgba(input, brightness, contrast, gamma, output);
return dest;
}