public G00TileDecoder(IBinaryStream input, ImageMetaData info, G00Entry entry) : base(input, info) { g00ent = entry; }
public override ArcFile TryOpen(ArcView file) { if (!file.Name.HasExtension(".g00")) { return(null); } if (file.View.ReadByte(0) != 2) { return(null); } uint width = file.View.ReadUInt16(1); uint height = file.View.ReadUInt16(3); if (0 == width || width > 0x8000 || 0 == height || height > 0x8000) { return(null); } int count = file.View.ReadInt16(5); if (count <= 1 || count > 0x100) { return(null); } var base_name = Path.GetFileNameWithoutExtension(file.Name); uint index_offset = 9; var dir = new List <Entry> (count); for (int i = 0; i < count; ++i) { var entry = new G00Entry { Name = string.Format("{0}#{1:D3}", base_name, i), X = file.View.ReadInt32(index_offset), Y = file.View.ReadInt32(index_offset + 4), }; dir.Add(entry); index_offset += 0x18; } byte[] bitmap; using (var input = file.CreateStream(index_offset)) bitmap = G00Reader.LzDecompress(input, 2, 1); using (var input = new BinMemoryStream(bitmap)) { if (input.ReadInt32() != count) { return(null); } for (int i = 0; i < count; ++i) { dir[i].Offset = input.ReadUInt32(); dir[i].Size = input.ReadUInt32(); } } dir = dir.Where(e => e.Size != 0).ToList(); if (0 == dir.Count) { return(null); } var info = new ImageMetaData { Width = width, Height = height, BPP = 32 }; return(new G00Archive(file, this, dir, info, bitmap)); }
public override ArcFile TryOpen(ArcView file) { if (!file.Name.EndsWith (".g00", StringComparison.InvariantCultureIgnoreCase)) return null; if (file.View.ReadByte (0) != 2) return null; uint width = file.View.ReadUInt16 (1); uint height = file.View.ReadUInt16 (3); if (0 == width || width > 0x8000 || 0 == height || height > 0x8000) return null; int count = file.View.ReadInt16 (5); if (count <= 1 || count > 0x100) return null; var base_name = Path.GetFileNameWithoutExtension (file.Name); uint size = width * height * 4 + 0x12; // virtual TGA image size uint index_offset = 9; var dir = new List<Entry> (count); for (int i = 0; i < count; ++i) { var entry = new G00Entry { Name = string.Format ("{0}#{1:D3}.tga", base_name, i), X = file.View.ReadInt32 (index_offset), Y = file.View.ReadInt32 (index_offset+4), IsPacked = true, UnpackedSize = size, }; dir.Add (entry); index_offset += 0x18; } byte[] bitmap; using (var input = file.CreateStream (index_offset)) using (var bin = new BinaryReader (input)) bitmap = G00Reader.LzDecompress (bin, 2, 1); using (var input = new MemoryStream (bitmap)) using (var reader = new BinaryReader (input)) { if (reader.ReadInt32() != count) return null; for (int i = 0; i < count; ++i) { dir[i].Offset = reader.ReadUInt32(); dir[i].Size = reader.ReadUInt32(); } } dir = dir.Where (e => e.Size != 0).ToList(); if (0 == dir.Count) return null; var info = new ImageMetaData { Width = width, Height = height, BPP = 32 }; return new G00Archive (file, this, dir, info, bitmap); }