Skip to content

Commit

Permalink
IMAGES: Add support for animated tpc mipmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostritius authored and DrMcCoy committed May 26, 2019
1 parent 9c3767e commit 0af47aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
20 changes: 13 additions & 7 deletions src/images/tpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,20 @@ void TPC::readHeader(Common::SeekableReadStream &tpc, byte &encoding) {
tpc.skip(dataSize);
readTXIData(tpc);

_layerCount = 2;
_isAnimated = checkAnimated(width, height, dataSize);

if (_isAnimated) {
uint32 w = width;
uint32 h = height;
mipMapCount = 0;

while (w > 0 && h > 0) {
w /= 2;
h /= 2;
mipMapCount++;
}
}

tpc.seek(128);

uint32 minDataSize = 0;
Expand Down Expand Up @@ -170,9 +181,6 @@ void TPC::readHeader(Common::SeekableReadStream &tpc, byte &encoding) {
} else
throw Common::Exception("Unknown TPC encoding: %d (%d)", encoding, dataSize);

// Offset between the images.
_offset = dataSize - getDataSize(_format, width, height);

if (!hasValidDimensions(_format, width, height))
throw Common::Exception("Invalid dimensions (%dx%d) for format %d", width, height, _format);

Expand Down Expand Up @@ -217,7 +225,7 @@ void TPC::readHeader(Common::SeekableReadStream &tpc, byte &encoding) {

layerWidth >>= 1;
layerHeight >>= 1;
layerSize >>= 2;
layerSize = getDataSize(_format, layerWidth, layerHeight);

if ((layerWidth < 1) && (layerHeight < 1))
break;
Expand Down Expand Up @@ -323,8 +331,6 @@ void TPC::readData(Common::SeekableReadStream &tpc, byte encoding) {
if (tpc.read((*mipMap)->data.get(), (*mipMap)->size) != (*mipMap)->size)
throw Common::Exception(Common::kReadError);

tpc.skip(_offset);

// Unpacking 8bpp grayscale data into RGB
if (encoding == kEncodingGray) {
Common::ScopedArray<byte> dataGray((*mipMap)->data.release());
Expand Down
1 change: 0 additions & 1 deletion src/images/tpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class TPC : public Decoder {
Common::ScopedArray<byte> _txiData;
size_t _txiDataSize;

uint32 _offset;
bool _isAnimated;

// Loading helpers
Expand Down

0 comments on commit 0af47aa

Please sign in to comment.