protected List <OverlayBase> ReadImageResource(FileStream stream) { List <OverlayBase> guides = new List <OverlayBase>(); BinaryReader binaryReader = new BinaryReader(stream); try { int length = 0; byte[] bytes = binaryReader.ReadBytes(4); if (this.SwapBytes(bytes, 4)) { length = BitConverter.ToInt32(bytes, 0); } long streamLength = stream.Length; int bytesTotal = length; int bytesRed = 0; while (stream.Position < streamLength && bytesRed < bytesTotal) { byte[] osType = binaryReader.ReadBytes(4); bytesRed += 4; if (Encoding.ASCII.GetString(osType).Equals("8BIM")) { int imageResourceId = -1; bytes = binaryReader.ReadBytes(2); bytesRed += 2; if (this.SwapBytes(bytes, 2)) { imageResourceId = BitConverter.ToInt16(bytes, 0); } byte @byte = binaryReader.ReadByte(); bytesRed += 1; int nameSize = (int)@byte; if (nameSize > 0) { if (nameSize % 2 != 0) { @byte = binaryReader.ReadByte(); bytesRed += 1; } bytesRed += nameSize; } binaryReader.ReadByte(); bytesRed += 1; int size = 0; bytes = binaryReader.ReadBytes(4); if (this.SwapBytes(bytes, 4)) { size = BitConverter.ToInt32(bytes, 0); } bytesRed += 4; if ((size % 2) != 0) { size++; } if (size > 0) { if (imageResourceId == 1032) { binaryReader.ReadBytes(4); bytesRed += 4; binaryReader.ReadBytes(8); bytesRed += 8; int count = 0; bytes = binaryReader.ReadBytes(4); if (this.SwapBytes(bytes, 4)) { count = BitConverter.ToInt32(bytes, 0); } bytesRed += 4; if (count > 0) { for (int i = 0; i != count; i++) { int position = -1; bytes = binaryReader.ReadBytes(4); if (this.SwapBytes(bytes, 4)) { position = BitConverter.ToInt32(bytes, 0); } bytesRed += 4; byte direction = binaryReader.ReadByte(); bytesRed += 1; Guide guide = new Guide(); guide.Position = position / 32; guide.Orienation = direction == 0 ? Orienation.Vertical : Orienation.Horizontal; guides.Add(guide); } } } else { for (int n = 0; n < size; ++n) { byte c = binaryReader.ReadByte(); bytesRed += 1; } } } } } return(guides); } catch (Exception ex) { return(null); } }