public void SuccessRecompressView() { var package = Utils.LoadPackage(); //var r = package.GetResource("95.p56"); foreach (var r in package.GetResources <ResView>()) { if (r.Number == 460) { continue; // Skip broken view in Conquest } var info = r.GetInfo(); if (info.Method != 3) { continue; } var comp = info.GetCompressor(); var decomp = info.GetDecompressor(); var unpack = r.GetContent(); var compressed = comp.Pack(unpack); var ms = new MemoryStream(compressed); var uncompressed = decomp.Unpack(ms, compressed.Length, unpack.Length); //Assert.AreEqual(unpack, uncompressed, $"Decompress error in {r.FileName}"); var originalView = new SCIView(package); originalView.ReadVGA(unpack); var reorderView = new SCIView(package); reorderView.ReadVGA(uncompressed); Assert.AreEqual(originalView.Palette.Colors[3..], reorderView.Palette.Colors[3..]);
private void DetectFormat(byte[] data) { try { var view = new SCIView(Package); view.ReadVGA(data); Package.ViewFormat = ViewFormats.VGA; return; } catch { } try { var view = new SCIView(Package); view.ReadVGA11(data); Package.ViewFormat = ViewFormats.VGA1_1; return; } catch { } Package.ViewFormat = ViewFormats.Unknown; }
public SCIView GetView() { var data = GetContent(); var view = new SCIView(Package); if (Package.ViewFormat == ViewFormats.NotSet) { DetectFormat(data); } switch (Package.ViewFormat) { case ViewFormats.VGA: view.ReadVGA(data); break; case ViewFormats.VGA1_1: view.ReadVGA11(data); break; case ViewFormats.Unknown: throw new NotImplementedException(); } return(view); }