Exemple #1
0
 public TanReader(IBinaryStream input, TanMetaData info)
 {
     m_input  = input;
     m_output = new byte[info.Width * info.Height];
     m_info   = info;
     Format   = 8 == m_info.BPP ? PixelFormats.Indexed8 : PixelFormats.Bgr24;
 }
Exemple #2
0
        public override ArcFile TryOpen(ArcView file)
        {
            if (!file.Name.HasExtension(".tan"))
            {
                return(null);
            }
            int count = file.View.ReadInt16(0);

            if (!IsSaneCount(count))
            {
                return(null);
            }
            uint index_pos = 2 + (uint)count * 4;
            var  info      = new TanMetaData {
                Width      = file.View.ReadUInt16(index_pos),
                Height     = file.View.ReadUInt16(index_pos + 2),
                BPP        = 8,
                DataOffset = index_pos + 4,
            };

            index_pos += 0x404;
            count      = file.View.ReadInt16(index_pos);
            if (!IsSaneCount(count))
            {
                return(null);
            }
            index_pos += 2;

            var base_name   = Path.GetFileNameWithoutExtension(file.Name);
            var base_offset = index_pos + 4 * count;
            var dir         = new List <Entry> (count);

            for (int i = 0; i < count; ++i)
            {
                var entry = new TanEntry {
                    Name   = string.Format("{0}#{1:D2}", base_name, i),
                    Type   = "image",
                    Offset = base_offset + file.View.ReadUInt32(index_pos),
                    Index  = i,
                };
                dir.Add(entry);
                index_pos += 4;
            }
            for (int i = 1; i < count; ++i)
            {
                dir[i - 1].Size = (uint)(dir[i].Offset - dir[i - 1].Offset);
                if (!dir[i - 1].CheckPlacement(file.MaxOffset))
                {
                    return(null);
                }
            }
            dir[dir.Count - 1].Size = (uint)(file.MaxOffset - dir[dir.Count - 1].Offset);
            return(new TanArchive(file, this, dir, info));
        }
Exemple #3
0
 public TanArchive(ArcView arc, ArchiveFormat impl, ICollection <Entry> dir, TanMetaData info)
     : base(arc, impl, dir)
 {
     Info = info;
 }
Exemple #4
0
 public TanFrameDecoder(IBinaryStream input, TanMetaData info, int frame)
     : base(input, info)
 {
     m_frame  = frame;
     m_reader = new TanReader(m_input, info);
 }