Exemple #1
0
        public PBFile(byte[] pbdata)
        {
            Entries = new List <GenericArchiveEntry>();
            int numtextures = pbdata[4];

            for (int u = 0; u < numtextures; u++)
            {
                Entries.Add(new PBEntry(pbdata, 8 + 16 * u, u.ToString("D3") + ".pvr"));
                //Console.WriteLine("Added header {0}: offset {1}, pixel format {2}, data format {3}, GBIX {4}, width {5}, height {6}", u, hdr.Offset, hdr.PixelFormat, hdr.DataFormat, hdr.GBIX, hdr.Width, hdr.Height);
            }
            for (int u = 0; u < numtextures; u++)
            {
                PBEntry pbentry = (PBEntry)Entries[u];
                int     chunksize;
                if (u == numtextures - 1)
                {
                    chunksize = pbdata.Length - pbentry.Offset;
                }
                else
                {
                    PBEntry pbentry_1 = (PBEntry)Entries[u + 1];
                    chunksize = pbentry_1.Offset - pbentry.Offset;
                }
                byte[] headerless = new byte[chunksize];
                Array.Copy(pbdata, pbentry.Offset, headerless, 0, chunksize);
                pbentry.Data = pbentry.GetPVR(headerless);
                //Console.WriteLine("Added data: offset {0}, length {1}", headers[u].Offset, pbchunk.Length);
            }
        }
Exemple #2
0
        public int GetCurrentOffset(int index, int total)
        {
            int offset_base = 8 + 16 * total;

            if (index == 0)
            {
                return(offset_base);
            }
            for (int u = 0; u < index; u++)
            {
                PBEntry entry = (PBEntry)Entries[u];
                offset_base += entry.GetHeaderless().Length;
            }
            return(offset_base);
        }
Exemple #3
0
        public override byte[] GetBytes()
        {
            List <byte> result = new List <byte>();

            result.Add(0x50); // P
            result.Add(0x56); // B
            result.Add(0x42); // V
            result.Add(0x02); // Version ID
            result.AddRange(BitConverter.GetBytes((uint)Entries.Count));
            for (int u = 0; u < Entries.Count; u++)
            {
                PBEntry entry = (PBEntry)Entries[u];
                result.AddRange(entry.GetHeader());
            }
            for (int u = 0; u < Entries.Count; u++)
            {
                PBEntry entry = (PBEntry)Entries[u];
                result.AddRange(entry.GetHeaderless());
            }
            return(result.ToArray());
        }