1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 16:15:31 +00:00

Adjust NiPixelData loading

This commit is contained in:
Capostrophic 2020-05-13 01:25:39 +03:00
parent a08a9518c3
commit 5377e0491b
3 changed files with 19 additions and 10 deletions

View file

@ -163,11 +163,8 @@ void NiPixelData::read(NIFStream *nif)
{
fmt = (Format)nif->getUInt();
rmask = nif->getUInt(); // usually 0xff
gmask = nif->getUInt(); // usually 0xff00
bmask = nif->getUInt(); // usually 0xff0000
amask = nif->getUInt(); // usually 0xff000000 or zero
for (unsigned int i = 0; i < 4; ++i)
colorMask[i] = nif->getUInt();
bpp = nif->getUInt();
// 8 bytes of "Old Fast Compare". Whatever that means.
@ -190,10 +187,9 @@ void NiPixelData::read(NIFStream *nif)
}
// Read the data
unsigned int dataSize = nif->getUInt();
data.reserve(dataSize);
for (unsigned i=0; i<dataSize; ++i)
data.push_back((unsigned char)nif->getChar());
unsigned int numPixels = nif->getUInt();
if (numPixels)
nif->getUChars(data, numPixels);
}
void NiPixelData::post(NIFFile *nif)

View file

@ -124,7 +124,8 @@ public:
};
Format fmt;
unsigned int rmask, gmask, bmask, amask, bpp;
unsigned int colorMask[4];
unsigned int bpp;
NiPalettePtr palette;
unsigned int numberOfMipmaps;

View file

@ -200,6 +200,18 @@ public:
return result;
}
void getChars(std::vector<char> &vec, size_t size)
{
vec.resize(size);
readLittleEndianDynamicBufferOfType<char,char>(inp, vec.data(), size);
}
void getUChars(std::vector<unsigned char> &vec, size_t size)
{
vec.resize(size);
readLittleEndianDynamicBufferOfType<unsigned char,unsigned char>(inp, vec.data(), size);
}
void getUShorts(std::vector<unsigned short> &vec, size_t size)
{
vec.resize(size);