26 lines
773 B
C++
26 lines
773 B
C++
#include <algorithm>
|
|
|
|
#include "PaletteDecoder.hh"
|
|
#include "exceptions.hh"
|
|
|
|
PaletteDecoder::PaletteDecoder(uint8_t const* base, size_t length)
|
|
: iff_(base, length)
|
|
{
|
|
auto& root = iff_.getRoot();
|
|
if (!root.isForm())
|
|
throw FormatException{"Root node not FORM"};
|
|
|
|
auto& rootForm = dynamic_cast<IffFile::Form const&>(root);
|
|
if (rootForm.getSubtype() != "PALT")
|
|
throw FormatException{"Root form not PALT"};
|
|
|
|
for (auto paltIt = rootForm.childrenBegin();paltIt != rootForm.childrenEnd();++paltIt) {
|
|
if (paltIt->getType() == "INFO") {
|
|
} else if (paltIt->getType() == "PALT") {
|
|
std::transform(paltIt->begin()+4, paltIt->begin()+772,
|
|
palette_.begin(),
|
|
[](const char& in) -> uint8_t {return (in << 2) | ((in >> 6)&0x3);});
|
|
}
|
|
}
|
|
}
|