private void readDDS(string ddsPath, CNode node)
{
if (node == null) {
node = node = ((CNode)treeViewTextures.SelectedNode.Tag);
}
int nMML = 0;
using (BinaryReader b = new BinaryReader(File.Open(ddsPath, FileMode.Open))) {
// Skip first 12 bytes
b.ReadBytes(12);
// Height
node.attributes["height"].data = b.ReadInt32();
// Width
node.attributes["width"].data = b.ReadInt32();
// Skip 8
b.ReadBytes(8);
// numberMipMapLevels
nMML = b.ReadInt32() - 1;
if (nMML >= 0) {
node.attributes["numberMipMapLevels"].data = nMML;
} else {
node.attributes["numberMipMapLevels"].data = 0;
}
// Skip 52
b.ReadBytes(52);
// texelFormat
node.attributes["texelFormat"].data = Encoding.UTF8.GetString(b.ReadBytes(4)).ToLower();
// Skip 40
b.ReadBytes(40);
// Code
node.subNodes[0].subNodes[0].data = b.ReadBytes((int)(b.BaseStream.Length - (long)128));
// TEXTUREIMAGEBLOCKDATA-Size
//sections[sectionIndex + 2].Size = sections[sectionIndex + 2].Code.Length + 4;
// TEXTUREIMAGEBLOCK_size
node.subNodes[0].attributes["size"].data = node.subNodes[0].subNodes[0].data.Length;
// TEXTUREIMAGEBLOCK-Size
//sections[sectionIndex + 1].Size = bytesToInt(sections[sectionIndex + 1].Subsections["size"].Value) + sections[sectionIndex + 1].Size2 + 16;
}
}