コード例 #1
0
ファイル: ArcGAN.cs プロジェクト: zxc120/GARbro
        public byte[] GetFrame(GanEntry entry)
        {
            int index = entry.Index;

            if (Frames[index] != null)
            {
                return(Frames[index]);
            }

            byte[] ref_frame = null;
            if (entry.Ref != 0)
            {
                var ref_entry = Dir.Cast <GanEntry>().FirstOrDefault(e => e.Id == entry.Ref);
                if (ref_entry != null && ref_entry != entry)
                {
                    ref_frame = GetFrame(ref_entry);
                }
            }
            using (var stream = File.CreateStream(entry.Offset, entry.Size))
            {
                byte[] pixels;
                if (ref_frame != null)
                {
                    pixels = ref_frame.Clone() as byte[];
                    UnpackRefFrame(stream, pixels);
                }
                else
                {
                    pixels = new byte[(int)Info.Width * (int)Info.Height * 3];
                    UnpackKeyFrame(stream, pixels);
                }
                Frames[index] = pixels;
                return(pixels);
            }
        }
コード例 #2
0
ファイル: ArcGAN.cs プロジェクト: zxc120/GARbro
        public override ArcFile TryOpen(ArcView file)
        {
            if (!file.View.AsciiEqual(4, "0100"))
            {
                return(null);
            }
            int count = file.View.ReadInt32(12);

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

            for (int i = 0; i < count; ++i)
            {
                var entry = new GanEntry {
                    Name   = string.Format("{0}#{1:D2}", base_name, i),
                    Type   = "image",
                    Index  = i,
                    Id     = file.View.ReadInt32(index_offset),
                    Ref    = file.View.ReadInt32(index_offset + 4),
                    Offset = file.View.ReadUInt32(index_offset + 8),
                    Size   = file.View.ReadUInt32(index_offset + 12),
                };
                if (!entry.CheckPlacement(file.MaxOffset))
                {
                    return(null);
                }
                dir.Add(entry);
                index_offset += 0x10;
            }
            return(new GanFrameArchive(file, this, dir));
        }