implement RLE decode
This commit is contained in:
31
src/abr.cpp
31
src/abr.cpp
@@ -134,14 +134,39 @@ std::shared_ptr<ABR::Image> ABR::parse_vmem()
|
||||
auto rect = rrect();
|
||||
auto depth2 = ru16(); // again?
|
||||
auto compression = ru8(); // 1 = zip
|
||||
if (compression != 0 || depth != 8)
|
||||
if (depth != 8)
|
||||
{
|
||||
printf("unsupported depth %d bits\n", depth);
|
||||
skip(length - 23);
|
||||
continue;
|
||||
}
|
||||
if (compression == 0)
|
||||
{
|
||||
int data_size = (depth >> 3) * rect.area();
|
||||
ret->channels.emplace_back(depth, rect, compression, rraw(data_size));
|
||||
}
|
||||
else if (compression == 1)
|
||||
{
|
||||
auto height = rect.height();
|
||||
// contain the compressed length of each scanline
|
||||
std::vector<uint16_t> scanlines;
|
||||
scanlines.reserve(height);
|
||||
for (int i = 0; i < height; i++)
|
||||
scanlines.push_back(ru16());
|
||||
std::vector<uint8_t> raw;
|
||||
for (auto sl : scanlines)
|
||||
{
|
||||
auto decoded = rrle(sl);
|
||||
raw.insert(raw.end(), decoded.begin(), decoded.end());
|
||||
}
|
||||
ret->channels.emplace_back(depth, rect, compression, raw);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("unsupported compression mode %d\n", compression);
|
||||
skip(length - 23);
|
||||
continue;
|
||||
}
|
||||
int data_size = (depth >> 3) * rect.area();
|
||||
ret->channels.emplace_back(depth, rect, compression, rraw(data_size));
|
||||
}
|
||||
snap();
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user