Example #1
0
        Stream UnpackEntry(IBinaryStream input, MmaEntry entry)
        {
            uint flags = entry.Flags & 6;

            if (6 == flags && 0 == entry.HeaderSize)
            {
                using (input)
                {
                    var data = new byte[entry.UnpackedSize];
                    UnpackLz(input, data, 0);
                    return(new BinMemoryStream(data, entry.Name));
                }
            }
            else if (4 == flags)
            {
                using (input)
                {
                    input.Position = (int)entry.HeaderSize;
                    var data = input.ReadBytes((int)entry.UnpackedSize);
                    Decrypt(data, 0, data.Length);
                    return(new BinMemoryStream(data, entry.Name));
                }
            }
            return(input.AsStream);
        }
Example #2
0
 public MmeMaskDecoder(IBinaryStream input, MmaEntry entry) : base(input, entry)
 {
     m_width  = m_input.ReadInt32();
     m_height = m_input.ReadInt32();
     m_stride = m_width;
     Info     = new ImageMetaData {
         Width  = (uint)m_width,
         Height = (uint)m_height,
         BPP    = 8,
     };
     m_output = new byte[entry.UnpackedSize];
     Format   = PixelFormats.Gray8;
 }
Example #3
0
        void ReadMmaList(ArcView file, List <Entry> dir, MmaEntry index_entry)
        {
            using (var packed = file.CreateStream(index_entry.Offset, index_entry.Size))
                using (var unpacked = UnpackEntry(packed, index_entry))
                    using (var index = new StreamReader(unpacked, Encodings.cp932))
                    {
                        for (int i = 0; i < dir.Count; ++i)
                        {
//                    int type = index.Read();
//                    if (-1 == type)
//                        break;
                            var name = index.ReadLine();
                            if (null == name)
                            {
                                break;
                            }
                            dir[i].Name = Path.GetFileName(name);
                        }
                    }
        }
Example #4
0
 public MmeImageDecoder(IBinaryStream input, MmaEntry entry) : base(input, entry)
 {
     m_width  = m_input.ReadInt32();
     m_height = m_input.ReadInt32();
     m_bpp    = m_input.ReadInt32();
     m_stride = m_input.ReadInt32();
     Info     = new ImageMetaData {
         Width  = (uint)m_width,
         Height = (uint)m_height,
         BPP    = m_bpp,
     };
     m_output = new byte[entry.UnpackedSize];
     if (24 == m_bpp)
     {
         Format = PixelFormats.Bgr24;
     }
     else
     {
         Format = PixelFormats.Bgr32;
     }
 }
Example #5
0
        public override ArcFile TryOpen(ArcView file)
        {
            int version = file.View.ReadInt32(0xC);

            if (version != 1)
            {
                return(null);
            }
            int count = file.View.ReadInt32(0x10);

            if (!IsSaneCount(count))
            {
                return(null);
            }
            uint index_offset = file.View.ReadUInt32(4);

            if (index_offset >= file.MaxOffset)
            {
                return(null);
            }
            var base_name = Path.GetFileNameWithoutExtension(file.Name);
            var dir       = new List <Entry> (count);

            for (int i = 0; i < count; ++i)
            {
                var entry = new MmaEntry {
                    Name         = string.Format("{0}#{1:D5}", base_name, i),
                    Offset       = file.View.ReadUInt32(index_offset),
                    UnpackedSize = file.View.ReadUInt32(index_offset + 4),
                    Size         = file.View.ReadUInt32(index_offset + 8),
                    HeaderSize   = file.View.ReadUInt32(index_offset + 0x0C),
                    Flags        = file.View.ReadUInt32(index_offset + 0x10),
                };
                if (!entry.CheckPlacement(file.MaxOffset))
                {
                    return(null);
                }
                switch (entry.Flags & 0x38)
                {
                case 8:
                case 0x10:
                case 0x18:
                case 0x38:
                    entry.Type = "image";
                    break;

                default:
                    if (0x2D == entry.Flags)
                    {
                        entry.Type = "audio";
                    }
                    break;
                }
                dir.Add(entry);
                index_offset += 0x14;
            }
            var list_entry = dir[0] as MmaEntry;

            if (0x2F == list_entry.Flags)
            {
                ReadMmaList(file, dir, list_entry);
            }
            return(new ArcFile(file, this, dir));
        }
Example #6
0
 protected MmeBaseDecoder(IBinaryStream input, MmaEntry entry) : base(input)
 {
     m_header_size = (int)entry.HeaderSize;
     m_flags       = entry.Flags;
 }