-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSerum.cpp
77 lines (56 loc) · 1.84 KB
/
Serum.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
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
#include "Serum.h"
#include <cstring>
#include "Logger.h"
#include "serum-decode.h"
namespace DMDUtil
{
bool Serum::m_isLoaded = false;
Serum::Serum(int width, int height)
{
m_width = width;
m_height = height;
m_length = width * height;
}
Serum::~Serum()
{
Serum_Dispose();
m_isLoaded = false;
}
Serum* Serum::Load(const char* const altColorPath, const char* const romName)
{
if (m_isLoaded) return nullptr;
int width;
int height;
unsigned int numColors;
unsigned int numTriggers;
if (!Serum_Load(altColorPath, romName, &width, &height, &numColors, &numTriggers))
{
Serum_Dispose();
return nullptr;
}
Log("Serum loaded: romName=%s, width=%d, height=%d, numColors=%d, numTriggers=%d", romName, width, height, numColors,
numTriggers);
m_isLoaded = true;
return new Serum(width, height);
}
bool Serum::Convert(uint8_t* pFrame, uint8_t* pDstFrame, uint8_t* pDstPalette, uint16_t width, uint16_t height)
{
if (pFrame) memcpy(pDstFrame, pFrame, width * height);
unsigned int triggerId;
return Serum_ColorizeOrApplyRotations(pDstFrame ? pDstFrame : nullptr, width, height, pDstPalette, &triggerId);
};
void Serum::SetStandardPalette(const uint8_t* palette, const int bitDepth)
{
Serum_SetStandardPalette(palette, bitDepth);
}
bool Serum::ColorizeWithMetadata(uint8_t* frame, int width, int height, uint8_t* palette, uint8_t* rotations,
uint32_t* triggerID, uint32_t* hashcode, int* frameID)
{
return Serum_ColorizeWithMetadata(frame, width, height, palette, rotations, triggerID, hashcode, frameID);
}
void Serum::SetIgnoreUnknownFramesTimeout(int milliseconds)
{
return Serum_SetIgnoreUnknownFramesTimeout((uint16_t)milliseconds);
}
void Serum::SetMaximumUnknownFramesToSkip(int maximum) { return Serum_SetMaximumUnknownFramesToSkip((uint8_t)maximum); }
} // namespace DMDUtil