Esempio n. 1
0
        public override IImageDecoder OpenImage(ArcFile arc, Entry entry)
        {
            var tex = entry as TexEntry;

            if (null == tex)
            {
                return(base.OpenImage(arc, entry));
            }
            if ("TLG" == tex.TexType)
            {
                return(OpenTlg(arc, tex));
            }
            var info = new PsbTexMetaData
            {
                FullWidth  = tex.Width,
                FullHeight = tex.Height,
                Width      = (uint)tex.TruncatedWidth,
                Height     = (uint)tex.TruncatedHeight,
                TexType    = tex.TexType,
                BPP        = 32
            };
            var input = arc.File.CreateStream(entry.Offset, entry.Size);

            return(new PsbTextureDecoder(input, info));
        }
Esempio n. 2
0
        void ReadRgba8(Stream input, PsbTexMetaData meta, byte[] output)
        {
            int  dst_stride = (int)meta.Width * 4;
            long next_row   = meta.DataOffset;
            int  src_stride = meta.FullWidth * 4;
            int  dst        = 0;

            for (uint i = 0; i < meta.Height; ++i)
            {
                input.Position = next_row;
                input.Read(output, dst, dst_stride);
                dst      += dst_stride;
                next_row += src_stride;
            }
        }
Esempio n. 3
0
 public override ImageMetaData ReadMetaData(Stream stream)
 {
     stream.Position = 4;
     using (var reader = new BinaryReader(stream, Encoding.UTF8, true))
     {
         var info = new PsbTexMetaData {
             BPP = 32
         };
         info.DataOffset = reader.ReadInt32();
         info.FullWidth  = reader.ReadInt32();
         info.FullHeight = reader.ReadInt32();
         info.Width      = reader.ReadUInt32();
         info.Height     = reader.ReadUInt32();
         info.TexType    = reader.ReadString();
         return(info);
     }
 }
Esempio n. 4
0
        void ReadRgba4444(Stream input, PsbTexMetaData meta, byte[] output)
        {
            int dst_stride = (int)meta.Width * 4;
            int src_stride = meta.FullWidth * 2;
            int dst        = 0;
            var row        = new byte[src_stride];

            input.Position = meta.DataOffset;
            for (uint i = 0; i < meta.Height; ++i)
            {
                input.Read(row, 0, src_stride);
                int src = 0;
                for (int x = 0; x < dst_stride; x += 4)
                {
                    uint p = LittleEndian.ToUInt16(row, src);
                    src          += 2;
                    output[dst++] = (byte)((p & 0x000Fu) * 0xFFu / 0x000Fu);
                    output[dst++] = (byte)((p & 0x00F0u) * 0xFFu / 0x00F0u);
                    output[dst++] = (byte)((p & 0x0F00u) * 0xFFu / 0x0F00u);
                    output[dst++] = (byte)((p & 0xF000u) * 0xFFu / 0xF000u);
                }
            }
        }
Esempio n. 5
0
 public PsbTextureDecoder(IBinaryStream input, PsbTexMetaData info) : base(input, info)
 {
     m_info = info;
 }