74 e.
add(
"Failed reading NCLR file");
98 if ((versionMajor != 1) || (versionMinor != 0))
102 if (fileSize > nclr.
size())
106 if (headerSize != 16)
110 if ((sectionCount != 1) && (sectionCount != 2))
122 if ((depthValue != 3) && (depthValue != 4))
125 const uint8 depth = (depthValue == 3) ? 4 : 8;
131 if ((palSize == 0) || (palSize > size))
137 const uint32 colorCount = MIN<uint32>(1 << depth, palSize / 2) * 3;
139 nclr.
seek(startOffset);
143 for (
uint32 i = 0; i < colorCount; i += 3) {
146 palette[i + 0] = ((color >> 10) & 0x1F) << 3;
147 palette[i + 1] = ((color >> 5) & 0x1F) << 3;
148 palette[i + 2] = ( color & 0x1F) << 3;
152 static const byte kPink[3] = { 0xFF, 0x00, 0xFF };
153 for (
uint32 i = colorCount; i < 768; i +=
sizeof(kPink))
154 std::memcpy(palette.
get() + i, kPink,
sizeof(kPink));
Loading Nitro CoLoR palette files.
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like 'DATA', to ensure portability.
void add(const char *s,...) GCC_PRINTF(2
This is a wrapper around SeekableSubReadStream, but it adds non-endian read methods whose endianness ...
void reset(PointerType o=0)
Resets the pointer with the new value.
PointerType release()
Returns the plain pointer value and releases ScopedPtr.
static const byte * load(Common::SeekableReadStream &nclr)
Utility templates and functions for working with strings and streams.
static const uint32 kPLTTID
Exception that provides a stack of explanations.
size_t size() const
Obtains the total size of the stream, measured in bytes.
static const byte * readPalette(Common::SeekableSubReadStreamEndian &nclr)
A simple scoped smart pointer template.
static const uint32 kNCLRID
Basic exceptions to throw.
size_t seek(ptrdiff_t offset, Origin whence=kOriginBegin)
Sets the stream position indicator for the stream.
Utility templates and functions.
virtual size_t skip(ptrdiff_t offset)
Skip the specified number of bytes, adding that offset to the current position in the stream...
Basic reading stream interfaces.
static const byte * loadNCLR(Common::SeekableSubReadStreamEndian &nclr)
PointerType get() const
Returns the plain pointer value.
UString debugTag(uint32 tag, bool trim)
Create an elaborate string from an integer tag, for debugging purposes.
static Common::SeekableSubReadStreamEndian * open(Common::SeekableReadStream &stream)
Treat this stream as a Nitro file and return an endian'd stream according to its BOM.
Interface for a seekable & readable data stream.
byte readByte()
Read an unsigned byte from the stream and return it.
static void readHeader(Common::SeekableSubReadStreamEndian &nclr)