mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 17:29:55 +00:00
Fully read NiPixelData
This commit is contained in:
parent
606758d72f
commit
a9ac108382
2 changed files with 32 additions and 7 deletions
|
@ -154,7 +154,7 @@ void NiFloatData::read(NIFStream *nif)
|
||||||
|
|
||||||
void NiPixelData::read(NIFStream *nif)
|
void NiPixelData::read(NIFStream *nif)
|
||||||
{
|
{
|
||||||
nif->getInt(); // always 0 or 1
|
fmt = (Format)nif->getUInt();
|
||||||
|
|
||||||
rmask = nif->getInt(); // usually 0xff
|
rmask = nif->getInt(); // usually 0xff
|
||||||
gmask = nif->getInt(); // usually 0xff00
|
gmask = nif->getInt(); // usually 0xff00
|
||||||
|
@ -169,19 +169,23 @@ void NiPixelData::read(NIFStream *nif)
|
||||||
mips = nif->getInt();
|
mips = nif->getInt();
|
||||||
|
|
||||||
// Bytes per pixel, should be bpp * 8
|
// Bytes per pixel, should be bpp * 8
|
||||||
/*int bytes =*/ nif->getInt();
|
/* int bytes = */ nif->getInt();
|
||||||
|
|
||||||
for(int i=0; i<mips; i++)
|
for(int i=0; i<mips; i++)
|
||||||
{
|
{
|
||||||
// Image size and offset in the following data field
|
// Image size and offset in the following data field
|
||||||
/*int x =*/ nif->getInt();
|
Mipmap m;
|
||||||
/*int y =*/ nif->getInt();
|
m.width = nif->getInt();
|
||||||
/*int offset =*/ 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();
|
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)
|
void NiColorData::read(NIFStream *nif)
|
||||||
|
|
|
@ -105,9 +105,30 @@ public:
|
||||||
class NiPixelData : public Record
|
class NiPixelData : public Record
|
||||||
{
|
{
|
||||||
public:
|
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;
|
unsigned int rmask, gmask, bmask, amask;
|
||||||
int bpp, mips;
|
int bpp, mips;
|
||||||
|
|
||||||
|
struct Mipmap
|
||||||
|
{
|
||||||
|
int width, height;
|
||||||
|
int dataOffset;
|
||||||
|
};
|
||||||
|
std::vector<Mipmap> mipmaps;
|
||||||
|
|
||||||
|
std::vector<unsigned char> data;
|
||||||
|
|
||||||
void read(NIFStream *nif);
|
void read(NIFStream *nif);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue