private static VSIF_Entry PopulateEntry(MemoryStream image) { using BinaryReader bin_img = new BinaryReader(image, System.Text.Encoding.UTF8, true); long pnt = image.Position; VSIF_Entry Entry = new VSIF_Entry() { CRC = bin_img.ReadUInt32(), Offset = bin_img.ReadUInt32(), Size = bin_img.ReadUInt32(), SummaryOffset = bin_img.ReadUInt32() }; image.Seek(pnt, SeekOrigin.Begin); return(Entry); //BinaryReader bin_img = new BinaryReader(image); //bin_img.Close(); }
private static void ExtractScene(ref MemoryStream image, int i, VSIF_Header Header) { //VSIF_Header sceneHeader = PopulateHeader(image); UInt32 entryStart = (UInt32)(Header.EntryOffset + (i * sizeof(UInt32) * 4)); image.Seek(entryStart, SeekOrigin.Begin); VSIF_Entry Entry = PopulateEntry(image); MemoryStream SceneBuffer; FileStream VCDFile = null; UInt32 SceneBufferSize = UncompressScene(ref image, Entry.Offset, out SceneBuffer, Entry.Size); if (SceneBufferSize == 0) { Console.Error.WriteLine("Failed to uncompress scene with CRC {0}", Entry.CRC); return; } //if (BVCDDecompiler.OpenVCDForWriting(out VCDFile,Entry.CRC)) //{ //} // throw new NotImplementedException(); BVCDDecompiler.OpenVCDForWriting(out VCDFile, Entry.CRC); SceneBuffer.Position = 0; image.Position = 0; if (VCDFile != null) { if (!BVCDDecompiler.Decompile(ref VCDFile, ref SceneBuffer, ref image)) { Console.WriteLine("Cannot decompile VCD with CRC {0:x}", Entry.CRC); } //VCDFile.Close(); } //SceneBuffer.Close(); //Close methods of BinaryReader and StringWriter close underlying streams by default }