public XI(Stream input) { using (var br = new BinaryReaderX(input)) { var header = br.ReadStruct <Header>(); Settings = new ImageSettings { Width = header.width, Height = header.height, Orientation = header.orientation, PadToPowerOf2 = false }; Settings.SetFormat(header.imageFormat); CombineFormat = header.combineFormat; if (CombineFormat != 1) { throw new Exception($"Unknown combine format {header.combineFormat}"); } var buf1 = CriWare.Decompress(input); while (input.Position % 4 != 0) { input.ReadByte(); } var buf2 = CriWare.Decompress(input); var ms = new MemoryStream(); for (int i = 0; i < buf1.Length / 2; i++) { int index = BitConverter.ToInt16(buf1, 2 * i); ms.Write(buf2, index * header.bytesPerTile, header.bytesPerTile); } Image = Common.Load(ms.ToArray(), Settings); } }
public BXLIM(Stream input) { using (var br = new BinaryReaderX(input)) { var tex = br.ReadBytes((int)br.BaseStream.Length - 40); sections = br.ReadSections(); switch (sections.Header.magic) { case "CLIM": BCLIMHeader = sections[0].Data.ToStruct <BCLIMImageHeader>(); Settings = new ImageSettings { Width = BCLIMHeader.width, Height = BCLIMHeader.height, Orientation = BCLIMHeader.orientation }; Settings.SetFormat(BCLIMHeader.format); UnknownShort = BCLIMHeader.unknown; break; case "FLIM": BFLIMHeader = sections[0].Data.ToStruct <BFLIMImageHeader>(); Settings = new ImageSettings { Width = BFLIMHeader.width, Height = BFLIMHeader.height, Orientation = BFLIMHeader.orientation }; Settings.SetFormat(BFLIMHeader.format); UnknownShort = BFLIMHeader.unknown; break; default: throw new NotSupportedException($"Unknown image format {sections.Header.magic}"); } Image = Common.Load(tex, Settings); } }
public JTEX(Stream input) { using (var br = new BinaryReaderX(input)) { JTEXHeader = br.ReadStruct <Header>(); Settings = new ImageSettings { Width = JTEXHeader.width, Height = JTEXHeader.height }; Settings.SetFormat(JTEXHeader.format); var texture2 = br.ReadBytes(JTEXHeader.unk3[0]); // bytes to read? Image = Common.Load(texture2, Settings); } }