mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-04 02:41:19 +00:00
Fully read NiPixelData
This commit is contained in:
parent
606758d72f
commit
a9ac108382
@ -154,7 +154,7 @@ void NiFloatData::read(NIFStream *nif)
|
||||
|
||||
void NiPixelData::read(NIFStream *nif)
|
||||
{
|
||||
nif->getInt(); // always 0 or 1
|
||||
fmt = (Format)nif->getUInt();
|
||||
|
||||
rmask = nif->getInt(); // usually 0xff
|
||||
gmask = nif->getInt(); // usually 0xff00
|
||||
@ -169,19 +169,23 @@ void NiPixelData::read(NIFStream *nif)
|
||||
mips = nif->getInt();
|
||||
|
||||
// Bytes per pixel, should be bpp * 8
|
||||
/*int bytes =*/ nif->getInt();
|
||||
/* int bytes = */ nif->getInt();
|
||||
|
||||
for(int i=0; i<mips; i++)
|
||||
{
|
||||
// Image size and offset in the following data field
|
||||
/*int x =*/ nif->getInt();
|
||||
/*int y =*/ nif->getInt();
|
||||
/*int offset =*/ nif->getInt();
|
||||
Mipmap m;
|
||||
m.width = nif->getInt();
|
||||
m.height = nif->getInt();
|
||||
m.dataOffset = nif->getInt();
|
||||
mipmaps.push_back(m);
|
||||
}
|
||||
|
||||
// Skip the data
|
||||
// Read the data
|
||||
unsigned int dataSize = nif->getInt();
|
||||
nif->skip(dataSize);
|
||||
data.reserve(dataSize);
|
||||
for (unsigned i=0; i<dataSize; ++i)
|
||||
data.push_back((unsigned char)nif->getChar());
|
||||
}
|
||||
|
||||
void NiColorData::read(NIFStream *nif)
|
||||
|
@ -105,9 +105,30 @@ public:
|
||||
class NiPixelData : public Record
|
||||
{
|
||||
public:
|
||||
enum Format
|
||||
{
|
||||
NIPXFMT_RGB8,
|
||||
NIPXFMT_RGBA8,
|
||||
NIPXFMT_PAL8,
|
||||
NIPXFMT_DXT1,
|
||||
NIPXFMT_DXT3,
|
||||
NIPXFMT_DXT5,
|
||||
NIPXFMT_DXT5_ALT
|
||||
};
|
||||
Format fmt;
|
||||
|
||||
unsigned int rmask, gmask, bmask, amask;
|
||||
int bpp, mips;
|
||||
|
||||
struct Mipmap
|
||||
{
|
||||
int width, height;
|
||||
int dataOffset;
|
||||
};
|
||||
std::vector<Mipmap> mipmaps;
|
||||
|
||||
std::vector<unsigned char> data;
|
||||
|
||||
void read(NIFStream *nif);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user