-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpalette.cpp
More file actions
48 lines (40 loc) · 851 Bytes
/
palette.cpp
File metadata and controls
48 lines (40 loc) · 851 Bytes
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
#include <string>
#ifdef QT_DEBUG
#include <iostream>
#endif
#include "palette.h"
Palette::Palette()
{
strcpy(name, "New palette");
n = 0;
}
Palette& Palette::operator=(const Palette &in)
{
in.getName(name);
this->clear();
for (int i = 0; i < in.size(); i++) {
this->addAt(i, in.getAt(i));
}
return *this;
}
void Palette::getName(char* name_) const
{
strcpy(name_, name);
}
void Palette::setName(char* name_)
{
strcpy(name, name_);
}
unsigned long Palette::getMergedAt(int i) const
{
if (i >= n || i < 0) { // out of bounds
#ifdef QT_DEBUG
std::cout<<"ERR: Palette::getMergedAt index out of bounds"<<std::endl;
#endif
exit(EXIT_TABLE_OUT_OF_BOUNDS);
}
return (elements[i].w << 24) |
(elements[i].x << 16) |
(elements[i].y << 8) |
elements[i].z;
}