bool ConvertToMp3(IBinaryStream input, Stream mp3, ushort schema) { byte[] frame_buffer = null; using (var output = new BinaryWriter(mp3, System.Text.Encoding.Default, true)) { while (input.PeekByte() != -1) { ushort rha_header = Binary.BigEndian(input.ReadUInt16()); uint header; int add_len = 0; byte add_value = 0; if (0 == schema) { header = 0xFFFB0000u | rha_header; } else { if (0 != (rha_header & 0x1000)) // RHAF_LASTZEROADD { add_len = input.ReadUInt16(); add_value = 0; } else if (0 != (rha_header & 0x2000)) // RHAF_LASTFULLADD { add_len = input.ReadUInt16(); add_value = 0xFF; } header = RhaToMp3Header(rha_header); } int frame_length = GetFrameLength(header); if (0 == frame_length || add_len > frame_length) { return(false); } if (null == frame_buffer || frame_length > frame_buffer.Length) { frame_buffer = new byte[frame_length]; } int read_length = frame_length - add_len; if (read_length != input.Read(frame_buffer, 0, read_length)) { break; } for (int i = 0; i < add_len; ++i) { frame_buffer[read_length + i] = add_value; } output.Write(Binary.BigEndian(header)); output.Write(frame_buffer, 0, frame_length); if (0 == (header & (1 << 16))) // CRC bit { output.Write(input.ReadUInt16()); } } } return(mp3.Length > 0); }
public override uint Signature { get { return 0; } } // 'RIFF' public override ImageMetaData ReadMetaData (IBinaryStream file) { // 'RIFF' isn't included into signature to avoid auto-detection of the WAV files as IPH images. if (0x46464952 != file.Signature) // 'RIFF' return null; var header = file.ReadHeader (0x10); if (0x38 != header.ToInt32 (4)) return null; var signature = header.ToInt32 (8); if (signature != 0x20485049 && signature != 0x00485049) // 'IPH' return null; if (0x20746D66 != header.ToInt32 (12)) // 'fmt ' return null; file.Position = 0x38; if (0x20706D62 != file.ReadInt32()) // 'bmp ' return null; var info = new IphMetaData(); info.PackedSize = file.ReadInt32(); info.Width = file.ReadUInt16(); info.Height = file.ReadUInt16(); file.Position = 0x50; info.BPP = file.ReadUInt16(); info.IsCompressed = 0 != file.ReadInt16(); // XXX int16@[0x54] is a transparency color or 0xFFFF if image is not transparent return info; }
} // 'YGP' public override ImageMetaData ReadMetaData(IBinaryStream stream) { stream.Position = 4; int mask_pos = stream.ReadUInt16(); // 04 byte type = stream.ReadUInt8(); // 06 if (type != 1 && type != 2) { return(null); } var info = new YgpMetaData { Type = type, BPP = 32 }; info.Flags = stream.ReadUInt8(); // 07 int header_size = stream.ReadInt32(); // 08 stream.Position = header_size; info.DataSize = stream.ReadInt32(); // XX+00 info.Width = stream.ReadUInt16(); // XX+04 info.Height = stream.ReadUInt16(); // XX+06 info.DataOffset = header_size + 8; if (0 != (info.Flags & 4)) { stream.Position = 0x14; info.OffsetX = stream.ReadInt16(); info.OffsetY = stream.ReadInt16(); } return(info); }
public override ImageMetaData ReadMetaData(IBinaryStream file) { int c1 = file.ReadByte(); int c2 = file.ReadByte(); if ('B' != c1 || 'M' != c2) { return(null); } uint size = file.ReadUInt32(); file.ReadUInt32(); uint image_offset = file.ReadUInt32(); uint header_size = file.ReadUInt32(); if (size < 14 + header_size) { // some otherwise valid bitmaps have size field set to zero if (size != 0 && size != 0xE || !file.AsStream.CanSeek) { return(null); } size = (uint)file.Length; } else if (file.AsStream.CanSeek) { if (size > file.Length) { size = (uint)file.Length; } } uint width, height; if (0xC == header_size) { width = file.ReadUInt16(); height = file.ReadUInt16(); } else if (header_size < 40 || size - 14 < header_size) { return(null); } else { width = file.ReadUInt32(); height = file.ReadUInt32(); } file.ReadInt16(); int bpp = file.ReadInt16(); return(new BmpMetaData { Width = width, Height = height, OffsetX = 0, OffsetY = 0, BPP = bpp, ImageLength = size, ImageOffset = image_offset, }); }
public override ImageMetaData ReadMetaData(IBinaryStream file) { if (!file.Name.HasExtension(".tan")) { return(null); } int count = file.ReadUInt16(); if (0 == count) { return(null); } file.Position = 2 + count * 4; uint w = file.ReadUInt16(); uint h = file.ReadUInt16(); if (0 == w || 0 == h) { return(null); } return(new TanMetaData { Width = w, Height = h, BPP = 8, DataOffset = (uint)file.Position, }); }
internal static CgdMetaData FromStream(IBinaryStream file, uint offset) { file.Position = offset; int unpacked_size = file.ReadInt32(); file.ReadInt32(); byte compression = (byte)file.ReadUInt16(); uint header_size = file.ReadUInt16(); uint id = file.ReadUInt32(); if (header_size < 0x10 || (id != 0x973768 && id != 0xB29EA4)) { return(null); } ushort width = file.ReadUInt16(); ushort height = file.ReadUInt16(); ushort bpp = file.ReadUInt16(); return(new CgdMetaData { Width = width, Height = height, BPP = bpp, DataOffset = offset + 0x10 + header_size, UnpackedSize = unpacked_size, Compression = compression, }); }
} // 'TYP1' public override ImageMetaData ReadMetaData(IBinaryStream stream) { stream.Position = 4; int bpp = stream.ReadByte(); bool has_palette = stream.ReadByte() != 0; var info = new Typ1MetaData { BPP = bpp }; info.Width = stream.ReadUInt16(); info.Height = stream.ReadUInt16(); uint packed_size = stream.ReadUInt32(); uint palette_size = 8 == bpp ? 0x400u : 0u; if (packed_size + palette_size + 0xE == stream.Length) { info.SeparateChannels = false; info.HasPalette = palette_size > 0; info.PackedSize = packed_size; } else { info.SeparateChannels = true; info.HasPalette = has_palette; info.Channel[0] = stream.ReadUInt32(); info.Channel[1] = stream.ReadUInt32(); info.Channel[2] = stream.ReadUInt32(); info.Channel[3] = stream.ReadUInt32(); } return(info); }
byte[] Unpack(int look_behind) { int dst = 0; int ctl = 2; while (dst < m_output.Length) { ctl >>= 1; if (1 == ctl) { ctl = m_input.ReadByte() | 0x100; } int count; if (0 != (ctl & 1)) { int src = m_input.ReadUInt16(); count = m_input.ReadByte(); if (dst > look_behind) { src += dst - look_behind; } Binary.CopyOverlapped(m_output, src, dst, count); } else { count = m_input.ReadByte(); m_input.Read(m_output, dst, count); } dst += count; } return(m_output); }
public override ImageMetaData ReadMetaData(IBinaryStream file) { if (0xFF != file.ReadByte() || 0xD8 != file.ReadByte()) { return(null); } while (-1 != file.PeekByte()) { ushort marker = Binary.BigEndian(file.ReadUInt16()); if ((marker & 0xff00) != 0xff00) { break; } int length = Binary.BigEndian(file.ReadUInt16()); if ((marker & 0x00f0) == 0xc0 && marker != 0xffc4) { if (length < 8) { break; } int bits = file.ReadByte(); uint height = Binary.BigEndian(file.ReadUInt16()); uint width = Binary.BigEndian(file.ReadUInt16()); int components = file.ReadByte(); return(new ImageMetaData { Width = width, Height = height, BPP = bits * components, }); } file.Seek(length - 2, SeekOrigin.Current); } return(null); }
public WadyInput(IBinaryStream input) : base(new MemoryStream()) { input.Seek(5, SeekOrigin.Begin); MulValue = input.ReadUInt8(); input.Seek(6, SeekOrigin.Current); int src_size = input.ReadInt32(); input.Seek(16, SeekOrigin.Current); var format = new WaveFormat(); format.FormatTag = input.ReadUInt16(); format.Channels = input.ReadUInt16(); format.SamplesPerSecond = input.ReadUInt32(); format.AverageBytesPerSecond = input.ReadUInt32(); format.BlockAlign = input.ReadUInt16(); format.BitsPerSample = input.ReadUInt16(); format.ExtraSize = 0; this.Format = format; int remaining = (int)(input.Length - input.Position); if (remaining == src_size) { (Source as MemoryStream).Capacity = src_size * 2; Decode(input, src_size, Source); } else { Decode2(input, Source); } Source.Position = 0; this.PcmSize = Source.Length; input.Dispose(); }
public override ImageMetaData ReadMetaData(IBinaryStream file) { var info = new AkbMetaData(); bool is_incremental = '+' == (file.ReadUInt32() >> 24); info.Width = file.ReadUInt16(); info.Height = file.ReadUInt16(); info.Flags = file.ReadUInt32(); info.BPP = 0 == (info.Flags & 0x40000000) ? 32 : 24; info.Background = file.ReadBytes(4); info.OffsetX = file.ReadInt32(); info.OffsetY = file.ReadInt32(); info.InnerWidth = file.ReadInt32() - info.OffsetX; info.InnerHeight = file.ReadInt32() - info.OffsetY; if (info.InnerWidth > info.Width || info.InnerHeight > info.Height) { return(null); } if (is_incremental) { info.BaseFileName = file.ReadCString(0x20); } info.DataOffset = (uint)file.Position; return(info); }
public override ImageMetaData ReadMetaData(IBinaryStream stream) { uint signature = ~stream.Signature; int bpp; switch (signature) { case 0x4c4c5546: /* fall through */ case 0x45555254: bpp = 24; break; case 0x48474948: bpp = 16; break; default: return(null); } stream.Position = 4; uint width = stream.ReadUInt16(); uint height = stream.ReadUInt16(); return(new DgdMetaData { Width = width, Height = height, BPP = bpp, // DGD extensions doesn't always mean encrypted contents XXX // IsEncrypted = stream.Name.HasExtension ("dgd"), }); }
public override Stream OpenEntry(ArcFile arc, Entry entry) { var pent = entry as PackedEntry; IBinaryStream input = arc.File.CreateStream(entry.Offset, entry.Size, entry.Name); if (null != pent && pent.IsPacked) { IBinaryStream unpacked; using (input) { var data = new byte[pent.UnpackedSize]; UnpackEntry(input.AsStream, data); unpacked = new BinMemoryStream(data, entry.Name); } input = unpacked; } if (input.Length > 4 && input.Length < 0x10000) { int unpacked_size = input.ReadUInt16(); int packed_size = input.ReadUInt16(); if (packed_size == input.Length - 4) { using (input) { var data = new byte[unpacked_size]; UnpackLz77(input.AsStream, data); return(new BinMemoryStream(data, entry.Name)); } } input.Position = 0; } return(input.AsStream); }
public override ImageMetaData ReadMetaData(IBinaryStream file) { file.Position = 4; int frames = file.ReadUInt16(); int bpp = file.ReadUInt16(); uint width = file.ReadUInt32(); uint height = file.ReadUInt32(); int x = file.ReadInt32(); int y = file.ReadInt32(); file.ReadInt32(); // 0 uint frame_size = file.ReadUInt32(); if (24 != bpp && 8 != bpp) { Trace.WriteLine("unsupported bpp", "WipFormat"); return(null); } return(new WipMetaData { Width = width, Height = height, OffsetX = x, OffsetY = y, BPP = bpp, FrameCount = frames, FrameSize = frame_size, }); }
public override ImageMetaData ReadMetaData(IBinaryStream file) { if (file.Signature != CRioArchive.ObjectSignature) { return(null); } var rio = new CRioArchive(file); uint signature; var class_ref = rio.LoadRioTypeCore(out signature); uint object_pos = (uint)file.Position; if ("CS5i" != class_ref) { return(null); } file.Seek(8, SeekOrigin.Current); return(new S5iMetaData { Width = file.ReadUInt16(), Height = file.ReadUInt16(), BPP = 32, ObjectOffset = object_pos, Schema = rio.Schema, }); }
byte[] UnpackCfp0(IBinaryStream input) { input.Position = 8; int unpacked_size = input.ReadInt32(); var output = new byte[unpacked_size]; int dst = 0; while (dst < output.Length) { int cmd = input.ReadByte(); int count = 0; switch (cmd) { case 0: count = input.ReadUInt8(); input.Read(output, dst, count); break; case 1: count = input.ReadInt32(); input.Read(output, dst, count); break; case 2: { count = input.ReadUInt8(); byte v = input.ReadUInt8(); for (int i = 0; i < count; ++i) { output[dst + i] = v; } break; } case 3: { count = input.ReadInt32(); byte v = input.ReadUInt8(); for (int i = 0; i < count; ++i) { output[dst + i] = v; } break; } case 6: int offset = input.ReadUInt16(); count = input.ReadUInt16(); Binary.CopyOverlapped(output, dst - offset, dst, count); break; case 15: case -1: return(output); } dst += count; } return(output); }
public void Unpack() { int pixels_remaining = m_data.Length; int data_pos = 0; int eax = 0; while (pixels_remaining > 0) { int count = eax * 3 + 3; if (count > pixels_remaining) { throw new InvalidFormatException(); } pixels_remaining -= count; if (count != m_input.Read(m_data, data_pos, count)) { throw new InvalidFormatException(); } data_pos += count; while (pixels_remaining > 0) { eax = m_input.ReadByte(); if (0 == (eax & 0x80)) { if (0x7f == eax) { eax += m_input.ReadUInt16(); } break; } int shift_index = eax >> 2; eax &= 3; if (3 == eax) { eax += m_input.ReadUInt16(); } count = eax * 3 + 3; if (pixels_remaining < count) { throw new InvalidFormatException(); } pixels_remaining -= count; int shift = ShiftTable[shift_index & 0x1f]; int shift_row = shift & 0x0f; shift >>= 4; shift_row *= (int)m_width; shift -= shift_row; shift *= 3; if (shift >= 0 || data_pos + shift < 0) { throw new InvalidFormatException(); } Binary.CopyOverlapped(m_data, data_pos + shift, data_pos, count); data_pos += count; } } }
} // 'Divided Picture' public override ImageMetaData ReadMetaData(IBinaryStream file) { var header = file.ReadHeader(0x30); if (!header.AsciiEqual("Divided Picture") || header.ToInt32(0x10) != 1) { return(null); } int version = header.ToInt32(0x14); if (version != 1 && version != 2) { return(null); } int info_pos = header.ToInt32(0x18); if (header.ToInt32(0x1C) < 4) { return(null); } int name_table_pos = header.ToInt32(0x20); int name_table_size = header.ToInt32(0x24); int layout_pos = header.ToInt32(0x28); file.Position = info_pos; ushort width = file.ReadUInt16(); ushort height = file.ReadUInt16(); file.Position = name_table_pos; int name_count = file.ReadUInt16(); if (name_count * 32 + 2 != name_table_size) { return(null); } var dir_name = VFS.GetDirectoryName(file.Name); var files = new List <string> (name_count); for (int i = 0; i < name_count; ++i) { var name = file.ReadCString(0x20); if (name.StartsWith(@".\")) { name = name.Substring(2); } name = VFS.CombinePath(dir_name, name); files.Add(name); } return(new DpoMetaData { Width = width, Height = height, BPP = 32, Version = version, LayoutOffset = layout_pos, Files = files, }); }
public byte[] Decode(IBinaryStream input) { m_dst = 0; if (1 == Channels) { var adp = new AdpDecoder(); while (input.PeekByte() != -1) { short sample = input.ReadInt16(); PutSample(sample); int quant_idx = input.ReadUInt16() & 0xFF; adp.Reset(sample, quant_idx); for (int j = 0; j < BytesPerChunk - 4; ++j) { byte octet = input.ReadUInt8(); PutSample(adp.DecodeSample(octet)); PutSample(adp.DecodeSample(octet >> 4)); } } } else { var first = new AdpDecoder(); var second = new AdpDecoder(); int samples_per_chunk = (BytesPerChunk - 8) / 8; while (input.PeekByte() != -1) { short sample = input.ReadInt16(); PutSample(sample); int quant_idx = input.ReadUInt16() & 0xFF; first.Reset(sample, quant_idx); sample = input.ReadInt16(); PutSample(sample); quant_idx = input.ReadUInt16() & 0xFF; second.Reset(sample, quant_idx); for (int j = 0; j < samples_per_chunk; ++j) { uint first_code = input.ReadUInt32(); uint second_code = input.ReadUInt32(); for (int i = 0; i < 8; ++i) { PutSample(first.DecodeSample((byte)first_code)); PutSample(second.DecodeSample((byte)second_code)); first_code >>= 4; second_code >>= 4; } } } } return(m_output); }
public override ImageMetaData ReadMetaData(IBinaryStream file) { file.Position = 4; var meta = new ImageMetaData(); meta.OffsetX = file.ReadInt16(); meta.OffsetY = file.ReadInt16(); meta.Width = file.ReadUInt16(); meta.Height = file.ReadUInt16(); meta.BPP = 32; return(meta); }
bool ReadHeader(bool encrypted) { m_input.Position = 4; m_version = m_input.ReadUInt16(); m_flags = m_input.ReadUInt16(); if (encrypted && m_version < 3) { m_flags = 2; } var header = m_input.ReadBytes(0x20); if (encrypted && 0 != (m_flags & 1)) { Decrypt(header, 0, 0x20); } m_names = LittleEndian.ToInt32(header, 0x04); m_strings = LittleEndian.ToInt32(header, 0x08); m_strings_data = LittleEndian.ToInt32(header, 0x0C); m_chunk_offsets = LittleEndian.ToInt32(header, 0x10); m_chunk_lengths = LittleEndian.ToInt32(header, 0x14); m_chunk_data = LittleEndian.ToInt32(header, 0x18); m_root = LittleEndian.ToInt32(header, 0x1C); int buffer_length = (int)m_input.Length; if (!(m_names >= 0x28 && m_names < m_chunk_data && m_strings >= 0x28 && m_strings < m_chunk_data && m_strings_data >= 0x28 && m_strings_data < m_chunk_data && m_chunk_offsets >= 0x28 && m_chunk_offsets < m_chunk_data && m_chunk_lengths >= 0x28 && m_chunk_lengths < m_chunk_data && m_chunk_data >= 0x28 && m_chunk_data <= buffer_length && m_root >= 0x28 && m_root < m_chunk_data)) { return(false); } if (null == m_data || m_data.Length < m_chunk_data) { m_data = new byte[m_chunk_data]; } int data_pos = (int)m_input.Position; m_input.Read(m_data, data_pos, m_chunk_data - data_pos); if (encrypted && 0 != (m_flags & 2)) { Decrypt(m_data, m_names, m_chunk_offsets - m_names); } // root object is a dictionary return(0x21 == m_data[m_root]); }
protected PackImageDecoder(IBinaryStream input, PixelFormat format) { m_input = input; uint width = input.ReadUInt16(); uint height = input.ReadUInt16(); Format = format; Info = new ImageMetaData { Width = width, Height = height, BPP = format.BitsPerPixel }; m_output = new byte[(int)width * (int)height * Info.BPP / 8]; }
internal GrxMetaData ReadInfo(IBinaryStream file) { var info = new GrxMetaData(); info.IsPacked = file.ReadByte() != 0; info.HasAlpha = file.ReadByte() != 0; info.BPP = file.ReadUInt16(); info.Width = file.ReadUInt16(); info.Height = file.ReadUInt16(); info.AlphaOffset = file.ReadInt32(); return(info); }
public List <Entry> Deserialize() { m_index.Position = 8; int count = Binary.BigEndian(m_index.ReadInt32()); m_name_list = new string[count]; for (int i = 0; i < count; ++i) { int length = m_index.ReadUInt8(); m_name_list[i] = m_index.ReadCString(length, Encoding.UTF8); } count = Binary.BigEndian(m_index.ReadInt32()); m_dir = new List <Entry> (count); for (int i = 0; i < count; ++i) { m_index.ReadUInt16(); ushort flags = Binary.BigEndian(m_index.ReadUInt16()); uint offset = Binary.BigEndian(m_index.ReadUInt32()); uint size = Binary.BigEndian(m_index.ReadUInt32()); var entry = new SxEntry { Flags = flags, Offset = (long)offset << 4, Size = size, IsPacked = 0 != (flags & 0x03), }; if (!entry.CheckPlacement(m_max_offset)) { return(null); } m_dir.Add(entry); } count = Binary.BigEndian(m_index.ReadUInt16()); for (int i = 0; i < count; ++i) { m_index.ReadUInt32(); m_index.ReadUInt32(); m_index.ReadUInt32(); Binary.BigEndian(m_index.ReadUInt32()); // archive body length m_index.ReadUInt64(); m_index.Seek(16, SeekOrigin.Current); // MD5 sum } count = Binary.BigEndian(m_index.ReadUInt16()); if (count > 0) { m_index.Seek(count * 24, SeekOrigin.Current); } DeserializeTree(); return(m_dir); }
void UnpackWithDictLarge() { var dict = new byte[m_max_dict_size * 3]; for (int y = 0; y < m_height;) { int dict_len = m_input.ReadUInt16() + 1; m_input.Read(dict, 0, dict_len * 3); for (int y_end = m_input.ReadUInt16(); y < y_end; y++) { var dst = y * m_stride; short line_size = m_input.ReadInt16(); if (line_size > 0) { if (dict_len > 256) { UnpackLine16(dst, line_size, dict); } else { UnpackLine8(dst, line_size, dict); } } else if (line_size < 0) { var src_line = (y + line_size) * m_stride; Buffer.BlockCopy(m_output, src_line, m_output, dst, m_stride); } else { for (int x = 0; x < m_width; x++) { int i; if (dict_len > 256) { i = m_input.ReadUInt16(); } else { i = m_input.ReadUInt8(); } i *= 3; m_output[dst] = dict[i]; m_output[dst + 1] = dict[i + 1]; m_output[dst + 2] = dict[i + 2]; dst += m_pixel_size; } } } } }
void Chunk40(int count) { int offset = m_input.ReadUInt16() * 4; int src = m_dst - offset; for (int i = 0; i < count; ++i) { m_output[m_dst] = m_output[src]; m_output[m_dst + 1] = m_output[src + 1]; m_output[m_dst + 2] = m_output[src + 2]; m_dst += 4; } }
/// <summary> /// Setup reader endianness accordingly. /// </summary> public void SetupReaders(int format, bool is_little_endian) { m_format = format; if (is_little_endian) { ReadUInt16 = () => m_input.ReadUInt16(); ReadUInt32 = () => m_input.ReadUInt32(); ReadInt16 = () => m_input.ReadInt16(); ReadInt32 = () => m_input.ReadInt32(); ReadInt64 = () => m_input.ReadInt64(); } else { ReadUInt16 = () => Binary.BigEndian(m_input.ReadUInt16()); ReadUInt32 = () => Binary.BigEndian(m_input.ReadUInt32()); ReadInt16 = () => Binary.BigEndian(m_input.ReadInt16()); ReadInt32 = () => Binary.BigEndian(m_input.ReadInt32()); ReadInt64 = () => Binary.BigEndian(m_input.ReadInt64()); } if (m_format >= 14 || m_format == 9) { Align = () => { long pos = m_input.Position; if (0 != (pos & 3)) { m_input.Position = (pos + 3) & ~3L; } }; } else { Align = () => {}; } if (m_format >= 14) { ReadId = ReadInt64; } else { ReadId = () => ReadInt32(); } if (m_format >= 22) { ReadOffset = ReadInt64; } else { ReadOffset = () => ReadUInt32(); } }
} // 'DGC' public override ImageMetaData ReadMetaData(IBinaryStream file) { file.Position = 4; var info = new DgcMetaData(); info.Flags = file.ReadUInt32(); info.Width = file.ReadUInt16(); info.Height = file.ReadUInt16(); if (info.Width > 0x7fff || info.Height > 0x7fff) { return(null); } info.BPP = 0 == (info.Flags & Reader.FlagAlphaChannel) ? 24 : 32; return(info); }
public override ImageMetaData ReadMetaData(IBinaryStream file) { file.Position = 3; int bpp = file.ReadByte(); int x = 0; int y = 0; int type = bpp; int header_size = 8; if (2 == type) { bpp = file.ReadByte(); header_size = 13; } else if (1 == type) { bpp = file.ReadByte(); x = file.ReadInt16(); y = file.ReadInt16(); header_size = 13; } else { type = 0; } if (8 != bpp && 24 != bpp && 32 != bpp) { return(null); } uint w = file.ReadUInt16(); uint h = file.ReadUInt16(); if (2 == type) { x = file.ReadInt16(); y = file.ReadInt16(); } return(new ElgMetaData { Width = w, Height = h, OffsetX = x, OffsetY = y, BPP = bpp, Type = type, HeaderSize = header_size, }); }
public override ImageData Read(IBinaryStream file, ImageMetaData info) { file.Position = 0xE; int total = (int)info.Width * (int)info.Height; var pixels = new byte[total + 15]; int dst = 0; while (dst < total) { int count = file.ReadUInt16(); if (count > 0x7FFF) { count &= 0x7FFF; file.Read(pixels, dst, count); dst += count; } else { byte c = file.ReadUInt8(); while (count-- > 0) { pixels[dst++] = c; } } } return(ImageData.Create(info, PixelFormats.Gray8, null, pixels)); }