Esempio n. 1
0
        public override ArcFile TryOpen(ArcView file)
        {
            int count = file.View.ReadInt32(4);

            if (!IsSaneCount(count))
            {
                return(null);
            }

            uint index_offset = 8;
            var  dir          = new List <Entry> (count);

            for (int i = 0; i < count; ++i)
            {
                uint name_length = file.View.ReadUInt32(index_offset);
                if (0 == name_length)
                {
                    return(null);
                }
                var name = file.View.ReadString(index_offset + 4, name_length);
                index_offset += 4 + name_length;
                var entry = new PcdEntry {
                    Name   = name,
                    Type   = "image",
                    Size   = file.View.ReadUInt32(index_offset + 8),
                    Offset = file.View.ReadUInt32(index_offset + 12),
                };
                if (!entry.CheckPlacement(file.MaxOffset))
                {
                    return(null);
                }
                entry.Info = new ImageMetaData {
                    Width  = file.View.ReadUInt32(index_offset),
                    Height = file.View.ReadUInt32(index_offset + 4),
                    BPP    = 8,
                };
                dir.Add(entry);
                index_offset += 16;
            }
            return(new ArcFile(file, this, dir));
        }
Esempio n. 2
0
        public override ArcFile TryOpen(ArcView file)
        {
            if (!file.View.AsciiEqual(0, "IMAGEDATE "))
            {
                return(null);
            }
            int count = file.View.ReadInt32(0xA);

            if (!IsSaneCount(count))
            {
                return(null);
            }
            long index_offset = 0xE;
            var  dir          = new List <Entry> (count);
            var  name_buffer  = new byte[0x100];

            for (int i = 0; i < count; ++i)
            {
                int left   = file.View.ReadInt32(index_offset + 8);
                int top    = file.View.ReadInt32(index_offset + 0xC);
                int right  = file.View.ReadInt32(index_offset + 0x10);
                int bottom = file.View.ReadInt32(index_offset + 0x14);
                index_offset += 0x18;
                int name_length = file.View.ReadInt32(index_offset);
                if (name_length <= 0)
                {
                    return(null);
                }
                if (name_length > name_buffer.Length)
                {
                    name_buffer = new byte[name_length];
                }
                file.View.Read(index_offset + 4, name_buffer, 0, (uint)name_length);
                DecryptName(name_buffer, 0, name_length);
                var name = Binary.GetCString(name_buffer, 0, name_length);
                index_offset += 4 + name_length;

                name_length = file.View.ReadInt32(index_offset);
                if (name_length > name_buffer.Length)
                {
                    name_buffer = new byte[name_length];
                }
                file.View.Read(index_offset + 4, name_buffer, 0, (uint)name_length);
                DecryptName(name_buffer, 0, name_length);
                var frame_name = Binary.GetCString(name_buffer, 0, name_length);
                if (frame_name != "NO NAME")
                {
                    frame_name = frame_name.Replace('/', '/');
                    name       = Path.Combine(name, frame_name);
                }
                index_offset += 4 + name_length;

                var entry = new PcdEntry {
                    Name   = name,
                    Type   = "image",
                    Offset = file.View.ReadUInt32(index_offset),
                };
                if (entry.Offset > file.MaxOffset)
                {
                    return(null);
                }
                entry.Info = new ImageMetaData {
                    Width   = (uint)(right - left),
                    Height  = (uint)(bottom - top),
                    OffsetX = left,
                    OffsetY = top,
                    BPP     = 32,
                };
                dir.Add(entry);
                index_offset += 4;
            }
            SetAdjacentEntriesSize(dir, file.MaxOffset);
            return(new ArcFile(file, this, dir));
        }
Esempio n. 3
0
 public PsdFormatDecoder(IBinaryStream input, PcdEntry entry) : base(input, entry.Info)
 {
 }