void Parse(Stream s) { s.Position = 0; BinaryReader r = new BinaryReader(s); uint magic = r.ReadUInt32(); if (checking) { if (magic != FOURCC("TRIM")) { throw new InvalidDataException(String.Format("Expected magic tag 0x{0:X8}; read 0x{1:X8}; position 0x{2:X8}", FOURCC("TRIM"), magic, s.Position)); } } version = r.ReadUInt32(); if (version == 3) { this.pt3entryList = new TRIMpt3EntryList(this.OnResourceChanged, s); } else { this.pt4entryList = new TRIMpt4EntryList(this.OnResourceChanged, s); } this.materialSetKey = new TGIBlock(recommendedApiVersion, null, s); // this is default order TGI this.hasFootprint = r.ReadByte(); }
public TRIMpt3EntryList ToTRIMpt3EntryList() //public IEnumerable<TRIMpt3Entry> ToTRIMpt3EntryList() { TRIMpt3EntryList result = new TRIMpt3EntryList(null); for (int i = 0; i < this.Count; i++) { result.Add(new TRIMpt3Entry(recommendedApiVersion, null, this[i].X, this[i].Y, this[i].V)); } return(result); }
protected override Stream UnParse() { MemoryStream ms = new MemoryStream(); BinaryWriter w = new BinaryWriter(ms); w.Write((uint)FOURCC("TRIM")); w.Write(version); if (version == 3) { if (this.pt3entryList == null) { if (this.pt4entryList == null) { this.pt3entryList = new TRIMpt3EntryList(this.OnResourceChanged); } else { this.pt3entryList = this.pt4entryList.ToTRIMpt3EntryList(); } } this.pt3entryList.UnParse(ms); } else { if (this.pt4entryList == null) { if (this.pt3entryList == null) { this.pt4entryList = new TRIMpt4EntryList(this.OnResourceChanged); } else { this.pt4entryList = this.pt3entryList.ToTRIMpt4EntryList(); } } this.pt4entryList.UnParse(ms); } if (this.materialSetKey == null) { this.materialSetKey = new TGIBlock(recommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.TGI); } this.materialSetKey.UnParse(ms); w.Write(hasFootprint); return(ms); }