ShpD2Frame[] ParseFrames(Stream s) { var start = s.Position; var imageCount = s.ReadUInt16(); // Last offset is pointer to end of file. var offsets = new uint[imageCount + 1]; var temp = s.ReadUInt32(); // If fourth byte in file is non-zero, the offsets are two bytes each. var twoByteOffset = (temp & 0xFF0000) > 0; s.Position = 2; for (var i = 0; i < imageCount + 1; i++) { offsets[i] = (twoByteOffset ? s.ReadUInt16() : s.ReadUInt32()) + 2; } var frames = new ShpD2Frame[imageCount]; for (var i = 0; i < frames.Length; i++) { s.Position = offsets[i]; frames[i] = new ShpD2Frame(s); } s.Position = start; return(frames); }
ShpD2Frame[] ParseFrames(Stream s) { var start = s.Position; var imageCount = s.ReadUInt16(); // Last offset is pointer to end of file. var offsets = new uint[imageCount + 1]; var temp = s.ReadUInt32(); // If fourth byte in file is non-zero, the offsets are two bytes each. var twoByteOffset = (temp & 0xFF0000) > 0; s.Position = 2; for (var i = 0; i < imageCount + 1; i++) offsets[i] = (twoByteOffset ? s.ReadUInt16() : s.ReadUInt32()) + 2; var frames = new ShpD2Frame[imageCount]; for (var i = 0; i < frames.Length; i++) { s.Position = offsets[i]; frames[i] = new ShpD2Frame(s); } s.Position = start; return frames; }