public void Load(BinaryReaderBE reader) { Width = reader.ReadInt16(); Height = reader.ReadInt16(); bytesPerRow = reader.ReadInt16(); flags = (BitmapFlags)reader.ReadUInt16(); BitDepth = reader.ReadInt16(); int scanlines = ColumnOrder ? Width : Height; reader.BaseStream.Seek(20 + scanlines * 4, SeekOrigin.Current); data = new byte[Width * Height]; if (bytesPerRow > -1) { // not compressed // if (ColumnOrder) { // // rotate // short temp = Width; // Width = Height; // Height = temp; // for (int y = Height - 1; y >= 0; --y) { // for (int x = 0; x < Width; ++x) { // data[x + y * Width] = reader.ReadByte(); // } // } // } else { reader.Read(data, 0, Width * Height); // } } else { ColumnOrder = false; for (int x = 0; x < Width; x++) { short start = reader.ReadInt16(); short end = reader.ReadInt16(); for (int y = start; y < end; y++) { data[x + y * Width] = reader.ReadByte(); } // int dstp = x + start * Width; // while (start != end) { // data[dstp] = reader.ReadByte(); // dstp += Width; // start++; // } } } }
public void Load(BinaryReaderBE reader) { Width = reader.ReadInt16(); Height = reader.ReadInt16(); bytesPerRow = reader.ReadInt16(); flags = (BitmapFlags)reader.ReadUInt16(); BitDepth = reader.ReadInt16(); int scanlines = ColumnOrder ? Width : Height; reader.BaseStream.Seek(20 + scanlines * 4, SeekOrigin.Current); data = new byte[Width * Height]; if (bytesPerRow > -1) { // not compressed if (ColumnOrder) { // rotate short temp = Width; Width = Height; Height = temp; for (int y = Height - 1; y >= 0; --y) { for (int x = 0; x < Width; ++x) { data[x + y * Width] = reader.ReadByte(); } } } else { reader.Read(data, 0, Width * Height); } } else { for (int x = 0; x < Width; ++x) { short start = reader.ReadInt16(); short end = reader.ReadInt16(); for (int y = start; y < end; ++y) { data[x + y * Width] = reader.ReadByte(); } } } }