public override ImageData Read(IBinaryStream file, ImageMetaData info) { var meta = (TxMetaData)info; PixelFormat format; BitmapPalette palette = null; if (24 == info.BPP) { format = PixelFormats.Bgr24; } else if (32 == info.BPP) { format = PixelFormats.Bgra32; } else if (16 == info.BPP) { format = PixelFormats.Bgr555; } else if (8 == info.BPP) { format = PixelFormats.Indexed8; file.Position = 0x36; palette = ReadPalette(file.AsStream, meta.Colors); } else { throw new InvalidFormatException(); } var reader = new TxReader(file, meta); var pixels = reader.Unpack(); return(ImageData.CreateFlipped(info, format, palette, pixels, reader.Stride)); }
protected override ImageData GetImageData() { m_input.Position = 4; var info = new TxMetaData { BPP = 8, Colors = 0x100 }; this.Info = info; info.Stride = m_input.ReadUInt16(); info.Height = m_input.ReadUInt16(); info.Width = (uint)info.Stride; info.DataOffset = m_input.Position; var reader = new TxReader(m_input, info); var pixels = reader.Unpack(); return(ImageData.CreateFlipped(Info, PixelFormats.Indexed8, Palette, pixels, info.Stride)); }