diff --git a/components/nif/data.cpp b/components/nif/data.cpp index eb707e1bf..2c5568397 100644 --- a/components/nif/data.cpp +++ b/components/nif/data.cpp @@ -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) diff --git a/components/nif/data.hpp b/components/nif/data.hpp index a0d4960e0..39901b584 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -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; diff --git a/components/nif/nifstream.hpp b/components/nif/nifstream.hpp index c78377448..97075c288 100644 --- a/components/nif/nifstream.hpp +++ b/components/nif/nifstream.hpp @@ -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);