From b28711d999c86c40a11f61846ab15685c2fc172b Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 3 Mar 2011 16:06:06 +0100 Subject: added (untested) CMPR compression based on BrawlLib's code. --- NW4RTools/Texture.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'NW4RTools/Texture.cs') diff --git a/NW4RTools/Texture.cs b/NW4RTools/Texture.cs index 078fa6b..3dadce8 100644 --- a/NW4RTools/Texture.cs +++ b/NW4RTools/Texture.cs @@ -228,7 +228,26 @@ namespace NW4RTools { } } - + break; + + case TextureFormat.CMPR: + // the texture format from hell + for (int y = 0; y < height; y += 8) { + for (int x = 0; x < width; x += 8) { + for (int iBlockY = 0; iBlockY < 2; iBlockY++) { + for (int iBlockX = 0; iBlockX < 2; iBlockX++) { + var block = Util.NVDXT.compressDXT1a(bits.Scan0, + x + (iBlockX * 4), y + (iBlockY * 4), + bits.Stride, bits.Height); + + data.WriteUInt16(block.Color0); + data.WriteUInt16(block.Color1); + data.WriteUInt32(block.Lookup); + } + } + } + } + break; } -- cgit v1.2.3