public static string[] ReadZeroTerminatedStringArrays(LimitedReader partialReader, bool withOffsets, out Dictionary <int, string>?offsets) { List <string> textures = new(); offsets = withOffsets ? new() : null; var startOffset = partialReader.Offset; while (!partialReader.IsFinished()) { int start = partialReader.Offset; while (partialReader.ReadByte() != 0) { ; } int end = partialReader.Offset - 1; if (end == start && partialReader.IsFinished()) { break; } partialReader.Offset = start; var textureNameBytes = partialReader.ReadBytes(end - start); var textureName = System.Text.Encoding.ASCII.GetString(textureNameBytes); textures.Add(textureName); if (withOffsets) { offsets ![start - startOffset] = textureName;
public BLP(byte[] bytes, int start, int length) { var reader = new MemoryBinaryReader(bytes, start, length); Header = new BLPHeader(reader); uint w = Header.Width; uint h = Header.Height; Data = new Rgba32[Header.MipCount][]; int mipLevel; for (mipLevel = 0; mipLevel < Header.MipCount; ++mipLevel) { reader.Offset = (int)Header.GetMipOffset(mipLevel); var mipReader = new LimitedReader(reader, (int)Header.GetMipSize(mipLevel)); if (Header.ColorEncoding == ColorEncoding.Palette) { uint len = w * h; Data[mipLevel] = new Rgba32[w * h]; for (int j = 0; j < len; j++) { var b = mipReader.ReadByte(); var color = Header.PaletteBGRA ![b];