Added a new constructor to the SNESPalette though I believe the data is still corrupt somehow

This commit is contained in:
scawful
2022-06-14 09:38:09 -04:00
parent 389c7c35f0
commit e79e159d30
2 changed files with 14 additions and 0 deletions

View File

@@ -52,6 +52,19 @@ SNESPalette::SNESPalette(char* data) {
}
}
SNESPalette::SNESPalette(const unsigned char* snes_pal) {
assert((sizeof(snes_pal) % 4 == 0) && (sizeof(snes_pal) <= 32));
size_ = sizeof(snes_pal) / 2;
for (unsigned i = 0; i < sizeof(snes_pal); i += 2) {
SNESColor col;
col.snes = snes_pal[i + 1] << (uint16_t) 8;
col.snes = col.snes | snes_pal[i];
m_color mColor = convertcolor_snes_to_rgb(col.snes);
col.rgb = ImVec4(mColor.red, mColor.green, mColor.blue, 1.f);
colors.push_back(col);
}
}
SNESPalette::SNESPalette(std::vector<ImVec4> cols) {
for (const auto& each : cols) {
SNESColor scol;

View File

@@ -31,6 +31,7 @@ class SNESPalette {
SNESPalette() = default;
explicit SNESPalette(uint8_t mSize);
explicit SNESPalette(char* snesPal);
explicit SNESPalette(const unsigned char* snes_pal);
explicit SNESPalette(std::vector<ImVec4>);
char* encode();