diff options
author | Treeki <treeki@gmail.com> | 2011-03-03 16:06:06 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-03-03 16:06:06 +0100 |
commit | b28711d999c86c40a11f61846ab15685c2fc172b (patch) | |
tree | 8081c5b31a93934b0b6670c6332f5eedb7502956 /NW4RTools/Texture.cs | |
parent | ab340fe4dc87086336643b6b616df6efdfac796b (diff) | |
download | nw4rtools-b28711d999c86c40a11f61846ab15685c2fc172b.tar.gz nw4rtools-b28711d999c86c40a11f61846ab15685c2fc172b.zip |
added (untested) CMPR compression based on BrawlLib's code.
Diffstat (limited to '')
-rw-r--r-- | NW4RTools/Texture.cs | 21 |
1 files changed, 20 insertions, 1 deletions
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; } |