} // '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); }
public Reader(Stream input, Typ1MetaData info) { m_width = (int)info.Width; m_height = (int)info.Height; m_info = info; m_pixel_size = 8 == m_info.BPP ? 1 : 4; m_output = new byte[m_width * m_height * m_pixel_size]; if (8 == m_info.BPP) { Format = m_info.HasPalette ? PixelFormats.Indexed8 : PixelFormats.Gray8; } else if (24 == m_info.BPP) { Format = PixelFormats.Bgr32; } else if (32 == m_info.BPP) { Format = PixelFormats.Bgra32; } else { throw new InvalidFormatException("Invalid CPB color depth"); } m_input = input; }
public Reader(Stream input, Typ1MetaData info) { m_width = (int)info.Width; m_height = (int)info.Height; m_bpp = info.BPP; m_pixel_size = 8 == m_bpp ? 1 : 4; m_channel = info.Channel; m_output = new byte[m_width * m_height * m_pixel_size]; if (8 == m_bpp) { Format = info.HasPalette ? PixelFormats.Indexed8 : PixelFormats.Gray8; } else if (24 == m_bpp) { Format = PixelFormats.Bgr32; } else if (32 == m_bpp) { Format = PixelFormats.Bgra32; } else { throw new InvalidFormatException("Invalid CPB color depth"); } m_input = input; if (info.HasPalette) { m_input.Position = 0x1E; Palette = ReadPalette(); } }
public override ImageMetaData ReadMetaData(Stream stream) { stream.Position = 4; int bpp = stream.ReadByte(); bool has_palette = stream.ReadByte() != 0; using (var input = new ArcView.Reader(stream)) { var info = new Typ1MetaData { BPP = bpp, HasPalette = has_palette }; info.Width = input.ReadUInt16(); info.Height = input.ReadUInt16(); input.ReadInt32(); info.Channel[0] = input.ReadUInt32(); info.Channel[1] = input.ReadUInt32(); info.Channel[2] = input.ReadUInt32(); info.Channel[3] = input.ReadUInt32(); return(info); } }