mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-15 06:52:34 +02:00
Quick unpalettising code
This commit is contained in:
parent
519c51f7ce
commit
e94c045ab7
@ -218,12 +218,31 @@ void dumpTextureDictionary(char* data, size_t& dataI)
|
||||
|
||||
auto native = readStructure<BSTextureNative>(data, dataI);
|
||||
std::cout << "Texture Info" << std::endl;
|
||||
std::cout << " Platform = " << std::hex << (native.platform) << std::endl;
|
||||
std::cout << " Width = " << std::dec << native.width << std::endl;
|
||||
std::cout << " Height = " << std::dec << native.height << std::endl;
|
||||
std::cout << " UV Wrap = " << std::hex << (native.wrapU+0) << "/" << (native.wrapV+0) << std::endl;
|
||||
std::cout << " Format = " << std::hex << (native.rasterformat) << std::endl;
|
||||
std::cout << " Name = " << std::string(native.diffuseName, 32) << std::endl;
|
||||
std::cout << " Alpha = " << std::string(native.alphaName, 32) << std::endl;
|
||||
std::cout << " DXT = " << std::hex << (native.dxttype+0) << std::endl;
|
||||
|
||||
if(native.rasterformat & BSTextureNative::FORMAT_EXT_PAL8)
|
||||
{
|
||||
// Read the palette
|
||||
auto palette = readStructure<BSPaletteData>(data, dataI);
|
||||
|
||||
// We can just do this for the time being until we need to compress or something
|
||||
uint32_t fullcolor[native.width * native.height];
|
||||
|
||||
for(size_t y = 0; y < native.height; ++y)
|
||||
{
|
||||
for(size_t x = 0; x < native.width; ++x)
|
||||
{
|
||||
fullcolor[(y*native.width)+x] = palette.palette[static_cast<size_t>(data[dataI+(y*native.width)+x])];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
dataI = basloc + textureHeader.size;
|
||||
}
|
||||
|
@ -223,6 +223,12 @@ namespace RW
|
||||
FORMAT_EXT_MIPMAP = 0x8000 // Mipmaps included
|
||||
};
|
||||
};
|
||||
|
||||
struct BSPaletteData
|
||||
{
|
||||
uint32_t palette[256];
|
||||
uint32_t rastersize;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user