-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresource.h
78 lines (57 loc) · 1.36 KB
/
resource.h
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
#ifndef RESOURCE_H
#define RESOURCE_H
#include <QPainterPath>
#include <QTransform>
#include <QtEndian>
struct Primitive
{
bool has_alpha;
int color_index;
QTransform transform;
int path_index;
};
struct Shape
{
QTransform transform;
QList<Primitive> primitives;
};
struct Palete { QColor colors[16]; };
class BigEndianStream
{
public:
static BigEndianStream fromFileInfo(const class QFileInfo &fi);
void seek(int pos) { _pos = pos; }
int pos() const { return _pos; }
template<typename T>
T next()
{
if (sizeof(T) == 1) {
T res = (T)_data[_pos];
_pos += 1;
return res;
}
else if (sizeof(T) == 2) {
auto data = (const uchar*)_data.constData();
T res = qFromBigEndian<T>(data + _pos);
_pos += 2;
return res;
}
}
private:
BigEndianStream(const QByteArray &data);
const QByteArray _data;
int _pos;
};
class POL
{
public:
POL(BigEndianStream stream);
const Palete & palette(int i) { return m_palettes.at(i); }
const QList<Primitive> & primitives(int i) { return m_primitives.at(i); }
const QPainterPath & path(int i) { return m_paths.at(i); }
private:
QVector<Palete> m_palettes;
QList<QList<Primitive> > m_primitives;
QList<QPainterPath> m_paths;
};
#endif // RESOURCE_H