public IMGZ(Stream file) { if (!file.CanRead || !file.CanSeek) { throw new NotSupportedException("Cannot read or seek in stream"); } this.file = new Crazycatz00.Utility.BinaryStream(file); switch (this.magic = this.file.ReadUInt32()) { case 0x5A474D49: //IMGZ #if DEBUG Debug.WriteLine(String.Format("num0: {0}\nnum1: {1}", this.file.ReadUInt32(), this.file.ReadUInt32())); #else file.Position += 8; #endif this.internalCount = this.file.ReadInt32(); Debug.Write("IMGZ "); break; case 0x44474D49: //IMGD this.internalCount = 1; Debug.Write("IMGD "); break; default: throw new InvalidDataException("Invalid signature"); } Debug.WriteLine("has " + this.internalCount + " items"); }
public TIM2(Stream file) { if (!file.CanRead || !file.CanSeek) { throw new NotSupportedException("Cannot read or seek in stream."); } this.file = new Crazycatz00.Utility.BinaryStream(file); const uint TIM2Signature = 'T' | ('I' << 8) | ('M' << 16) | ('2' << 24); if (this.file.ReadUInt32() != TIM2Signature) { throw new InvalidDataException("Invalid signature."); } byte formatVer = this.file.ReadByte(); if (formatVer != 3 && formatVer != 4 && formatVer != 0xEE) { throw new InvalidDataException("Invalid format version."); } switch (this.file.ReadByte()) { case 0: alignment = 16; break; case 1: alignment = 128; break; default: throw new InvalidDataException("Invalid format alignment."); } internalCount = this.file.ReadUInt16(); }