Example #1
0
        public override Stream OpenEntry(ArcFile arc, Entry entry)
        {
            // emulate TGA image
            var offset = entry.Offset;
            var info   = new Hg2MetaData
            {
                HeaderSize   = 0x4C,
                Width        = arc.File.View.ReadUInt32(offset),
                Height       = arc.File.View.ReadUInt32(offset + 4),
                BPP          = arc.File.View.ReadInt32(offset + 8),
                DataPacked   = arc.File.View.ReadInt32(offset + 0x14),
                DataUnpacked = arc.File.View.ReadInt32(offset + 0x18),
                CtlPacked    = arc.File.View.ReadInt32(offset + 0x1C),
                CtlUnpacked  = arc.File.View.ReadInt32(offset + 0x20),
                CanvasWidth  = arc.File.View.ReadUInt32(offset + 0x2C),
                CanvasHeight = arc.File.View.ReadUInt32(offset + 0x30),
                OffsetX      = arc.File.View.ReadInt32(offset + 0x34),
                OffsetY      = arc.File.View.ReadInt32(offset + 0x38),
            };

            using (var input = arc.File.CreateStream(entry.Offset, entry.Size))
                using (var reader = new Hg2Reader(input, info))
                {
                    return(TgaStream.Create(info, reader.Unpack(), true));
                }
        }
Example #2
0
 public override ImageData Read(Stream stream, ImageMetaData info)
 {
     using (var reader = new Hg2Reader(stream, (Hg2MetaData)info))
     {
         var pixels = reader.Unpack();
         var format = 24 == info.BPP ? PixelFormats.Bgr24 : PixelFormats.Bgra32;
         return(ImageData.CreateFlipped(info, format, null, pixels, reader.Stride));
     }
 }