Ejemplo n.º 1
0
 public void ReadFromStream(Stream stream)
 {
     BinaryReader br = new BinaryReader(stream);
     Magic = br.ReadBigUInt32();
     Unknown1 = br.ReadByte();
     Unknown2 = br.ReadByte();
     Format = (GtexPixelFromat)br.ReadByte();
     MipMapCount = br.ReadByte();
     Unknown3 = br.ReadByte();
     IsCubeMap = br.ReadByte() == 1;
     Width = br.ReadBigInt16();
     Height = br.ReadBigInt16();
     Depth = br.ReadBigInt16();
     LinerSize = br.ReadBigInt32();
     DataOffset = br.ReadBigInt32();
 }
        internal screenshotItem shotReach(BinaryReader br, int fileStart, screenshotItem screenshot)
        {
            int headerStart = (fileStart - 49152) / 4096;
            br.BaseStream.Position = fileStart + 4;
            int blfLength = br.ReadBigInt32();
            br.BaseStream.Position = fileStart + blfLength + 4;
            int chdrLength = br.ReadBigInt32();
            br.BaseStream.Position = fileStart + blfLength + 12;
            int blfVersion = br.ReadBigInt16();
            br.BaseStream.Position += 46; // Move forward 46 bytes to get to the mapID
            int mapId = br.ReadBigInt32();
            if (screenshot.gameID == 4 && mapId == 10080)
                mapId += 1; // This is done to prevent a discrepancy with Halo: Reach's "Installation 04"
            br.BaseStream.Position += 12; // Move forward 12 bytes to get to the created timestamp
            int createTime = br.ReadBigInt32();
            br.BaseStream.Position += 32;
            int modTime = br.ReadBigInt32();
            br.BaseStream.Position += 28; // Move forward 28 bytes to get to the title
            string shotTitle = Encoding.BigEndianUnicode.GetString(br.ReadBytes(256)).Trim('\0');
            br.BaseStream.Position = fileStart + blfLength + chdrLength + 4;
            int scncLength = br.ReadBigInt32();
            br.BaseStream.Position = screenshot.hashTable + ((headerStart * 24) + 21); // Since the header in Reach Retail screenshot files spans more than one block, we need to find out where to go next from the hash table
            int nextBlock = (br.ReadBigInt24() * 4096) + 49152;
            int bytesRemain = (blfLength + chdrLength + scncLength) - 4096;
            br.BaseStream.Position = nextBlock + bytesRemain + 12;
            int jpegLength = br.ReadBigInt32();
            int jpegOffset = (int)br.BaseStream.Position;

            screenshot.blfVersion = blfVersion;
            screenshot.headerLength = blfLength + chdrLength + scncLength + 16;
            screenshot.headerStart = headerStart;
            screenshot.jpegLength = jpegLength;
            screenshot.jpegOffset = jpegOffset;
            screenshot.mapID = mapId;
            screenshot.fileTime = createTime;
            screenshot.shotTitle = shotTitle;

            return screenshot;
        }
        internal screenshotItem shotReachBeta(BinaryReader br, int fileStart, screenshotItem screenshot)
        {
            br.BaseStream.Position = fileStart + 4;
            int blfLength = br.ReadBigInt32();
            br.BaseStream.Position = fileStart + blfLength + 4;
            int chdrLength = br.ReadBigInt32();
            br.BaseStream.Position = fileStart + blfLength + 12;
            int blfVersion = br.ReadBigInt16();
            br.BaseStream.Position += 46; // Move forward 46 bytes to get to the mapID
            int mapId = br.ReadBigInt32() + 10000;
            br.BaseStream.Position += 12; // Move forward 12 to get to the created time
            int shotTime = br.ReadBigInt32();
            br.BaseStream.Position += 64; // Move forward 64 bytes to get to the title
            string shotTitle = Encoding.BigEndianUnicode.GetString(br.ReadBytes(256)).Trim('\0');
            br.BaseStream.Position = fileStart + blfLength + chdrLength + 4;
            int scncLength = 0; // The scnc block doesn't exist in Halo: Reach Beta screenshots
            br.BaseStream.Position = fileStart + blfLength + chdrLength + scncLength + 12;
            int jpegLength = br.ReadBigInt32();
            int jpegOffset = (int)br.BaseStream.Position;

            screenshot.blfVersion = blfVersion;
            screenshot.headerLength = blfLength + chdrLength + scncLength + 16;
            screenshot.headerStart = (fileStart - 49152) / 4096;
            screenshot.jpegLength = jpegLength;
            screenshot.jpegOffset = jpegOffset;
            screenshot.mapID = mapId;
            screenshot.fileTime = shotTime;
            screenshot.shotTitle = shotTitle;

            return screenshot;
        }
        internal screenshotItem shotHalo3ODST(BinaryReader br, int fileStart, screenshotItem screenshot)
        {
            br.BaseStream.Position = fileStart + 4;
            int blfLength = br.ReadBigInt32();
            br.BaseStream.Position = fileStart + blfLength + 4;
            int chdrLength = br.ReadBigInt32();
            br.BaseStream.Position = fileStart + blfLength + 12;
            int blfVersion = br.ReadBigInt16();
            br.BaseStream.Position += 10; // Move forward 10 bytes to get to the start of the title
            string shotTitle = Encoding.BigEndianUnicode.GetString(br.ReadBytes(32)).Trim('\0');
            br.BaseStream.Position += 172; // Move forward 172 bytes to get to the shot time
            int shotTime = br.ReadBigInt32();
            br.BaseStream.Position += 8;
            int mapId = br.ReadBigInt32();
            br.BaseStream.Position += 8;
            byte fireFight = br.ReadByte();
            if (fireFight != 0)
                mapId += 10000 + fireFight;
            br.BaseStream.Position = fileStart + blfLength + chdrLength + 4;
            int scncLength = 0; // The scnc block doesn't exist in versions prior to 12070, so we'll check for that
            if (blfVersion >= 12070)
                scncLength = br.ReadBigInt32();
            br.BaseStream.Position = fileStart + blfLength + chdrLength + scncLength + 12;
            int jpegLength = br.ReadBigInt32();
            int jpegOffset = (int)br.BaseStream.Position;

            screenshot.blfVersion = blfVersion;
            screenshot.headerLength = blfLength + chdrLength + scncLength + 16;
            screenshot.headerStart = (fileStart - 49152) / 4096;
            screenshot.jpegLength = jpegLength;
            screenshot.jpegOffset = jpegOffset;
            screenshot.fileTime = shotTime;
            screenshot.mapID = mapId;
            screenshot.shotTitle = shotTitle;

            return screenshot;
        }