-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheffect.cpp
More file actions
85 lines (66 loc) · 1.4 KB
/
effect.cpp
File metadata and controls
85 lines (66 loc) · 1.4 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "effect.h"
#define MEM_ALIGNMENT 4
Effect::Effect(int _w, int _h) : w(_w), h(_h)
{
if (w % MEM_ALIGNMENT)
aligned_w = w + MEM_ALIGNMENT - (w % MEM_ALIGNMENT);
else
aligned_w = w;
vector_len = aligned_w * h;
bufferValue = new uchar[vector_len];
reset();
}
Effect::~Effect()
{
delete bufferValue;
}
int Effect::width()
{
return w;
}
int Effect::height()
{
return h;
}
void Effect::reset()
{
size_t len = static_cast<size_t>(vector_len)*sizeof(uchar);
memset(bufferValue, 0, len);
}
int Effect::getVectorIdx(int i, int j) const
{
return i + aligned_w * j;
}
uchar Effect::getValue(int i, int j) const
{
if (i >= 0 && i < w && j >= 0 && j < h)
return bufferValue[getVectorIdx(i, j)];
return static_cast<uchar>(-1);
}
void Effect::setValue(int i, int j, uchar value)
{
if (i >= 0 && i < w && j >= 0 && j < h)
bufferValue[getVectorIdx(i, j)] = value;
}
bool Effect::paint(QPainter *painter) const
{
if (!painter)
return false;
QImage img(bufferValue, w, h, QImage::Format_Indexed8);
img.setColorTable(palette());
painter->drawImage(0, 0, img);
return true;
}
QPair<int, QVector<QString>> Effect::fxKindList() const
{
return QPair<int, QVector<QString>> ();
}
void Effect::setFxKind(int kind)
{
Q_UNUSED(kind);
}
bool Effect::keyPressed(FxKey key)
{
Q_UNUSED(key);
return false;
}