/// <summary> /// Initializes a new instance of the <see cref="BLS"/> class. /// </summary> /// <param name="inData">The binary data containing the BLS file.</param> public BLS(byte[] inData) { using (var ms = new MemoryStream(inData)) { using (var br = new BinaryReader(ms)) { Header = new BLSHeader(br.ReadBytes(BLSHeader.GetSize())); for (var i = 0; i < Header.ShaderBlockCount; ++i) { var shaderBlock = new ShaderBlock(br.ReadBytes(ShaderBlock.GetSize())); shaderBlock.Data = br.ReadChars((int)shaderBlock.DataSize); Shaders.Add(shaderBlock); if ((ms.Position % 4) == 0) { continue; } var padCount = 4 - (ms.Position % 4); ms.Position += padCount; } } } }
public BLS(byte[] inData) { using (MemoryStream ms = new MemoryStream(inData)) { using (BinaryReader br = new BinaryReader(ms)) { this.Header = new BLSHeader(br.ReadBytes(BLSHeader.GetSize())); for (int i = 0; i < this.Header.ShaderBlockCount; ++i) { ShaderBlock shaderBlock = new ShaderBlock(br.ReadBytes(ShaderBlock.GetSize())); shaderBlock.Data = br.ReadChars((int)shaderBlock.DataSize); this.Shaders.Add(shaderBlock); if ((ms.Position % 4) != 0) { long padCount = 4 - (ms.Position % 4); ms.Position += padCount; } } } } }
/// <summary> /// Creates a new instance of the <see cref="BLS"/> class from supplied binary data. /// </summary> /// <param name="inData">The binary data containing the BLS file.</param> public BLS(byte[] inData) { using (MemoryStream ms = new MemoryStream(inData)) { using (BinaryReader br = new BinaryReader(ms)) { this.Header = new BLSHeader(br.ReadBytes(BLSHeader.GetSize())); for (int i = 0; i < this.Header.ShaderBlockCount; ++i) { ShaderBlock shaderBlock = new ShaderBlock(br.ReadBytes(ShaderBlock.GetSize())); shaderBlock.Data = br.ReadChars((int)shaderBlock.DataSize); this.Shaders.Add(shaderBlock); if ((ms.Position % 4) != 0) { long padCount = 4 - (ms.Position % 4); ms.Position += padCount; } } } } }