public DataFile(Reader reader) { int DataFileSize = (int)reader.BaseStream.Length; int headerSize = reader.ReadInt32(); Console.WriteLine(headerSize); int dircount = reader.ReadByte(); Console.WriteLine(dircount); Directories = new List <DirInfo>(); for (int d = 0; d < dircount; d++) { Directories.Add(new DirInfo(reader)); } for (int d = 0; d < dircount; d++) { if ((d + 1) < Directories.Count()) { while (reader.Pos - headerSize < Directories[d + 1].Address && !reader.IsEof) { FileInfo f = new FileInfo(reader); f.FullFileName = Directories[d].Directory + f.FileName; Files.Add(f); } } else { while (!reader.IsEof) { FileInfo f = new FileInfo(reader); f.FullFileName = Directories[d].Directory + f.FileName; Files.Add(f); } } } reader.Close(); }
public DirInfo(Reader reader) { Directory = reader.ReadString(); Console.WriteLine(Directory); Address = reader.ReadInt32(); }
public void read(Reader reader) { reader.ReadInt16(); // "BM" reader.ReadInt32(); // totalFileSize reader.ReadInt32(); // Unused int pixelPos = reader.ReadInt32(); reader.seek(14 + 4, System.IO.SeekOrigin.Begin); width = reader.ReadByte(); width |= reader.ReadByte() << 8; width |= reader.ReadByte() << 16; width |= reader.ReadByte() << 24; height = reader.ReadByte(); height |= reader.ReadByte() << 8; height |= reader.ReadByte() << 16; height |= reader.ReadByte() << 24; reader.BaseStream.Position += sizeof(ushort); bool indexed = reader.ReadUInt16() <= 8; //bpp if (!indexed) { throw new Exception("RSDK-Formatted Bitmap files must be indexed!"); } reader.BaseStream.Position += 4 * sizeof(int); int clrCount = reader.ReadInt32(); // how many colours used reader.seek(14 + 40, System.IO.SeekOrigin.Begin); for (int c = 0; c < clrCount; c++) { palette[c].B = reader.ReadByte(); palette[c].G = reader.ReadByte(); palette[c].R = reader.ReadByte(); reader.ReadByte(); // unused } long expectedPixelPos = (reader.BaseStream.Length - height * width); if (pixelPos != expectedPixelPos) { throw new Exception("RSDK-Formatted Bitmap files must end with the pixel data!"); } // This is how RSDK does it but there's a small chance it could maybe be wrong reader.seek(expectedPixelPos, System.IO.SeekOrigin.Begin); pixels = new byte[width * height]; int gfxPos = width * (height - 1); for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { pixels[gfxPos++] = reader.ReadByte(); } gfxPos -= 2 * width; } reader.Close(); }
public void read(Reader reader) { directory = reader.readRSDKString(); startOffset = reader.ReadInt32(); }
public GlobalVariable(Reader reader) { Name = reader.ReadString(); //Console.WriteLine(Name); Value = reader.ReadInt32(); }