示例#1
0
        public void LoadTexture(byte[] sha1, string path)
        {
            currPath     = path;
            rtb1.Text    = "";
            currTexture  = null;
            rawResBuffer = main.Host.getDataBySha1(sha1);
            exportResRawToolStripMenuItem.Enabled      = false;
            importFromDDSToolStripMenuItem.Enabled     = false;
            makeModJobFromDDSToolStripMenuItem.Enabled = false;
            if (rawResBuffer == null)
            {
                return;
            }
            exportResRawToolStripMenuItem.Enabled = true;
            ProcessTexture();
            exportAsDDSToolStripMenuItem.Enabled               =
                importFromDDSToolStripMenuItem.Enabled         =
                    makeModJobFromDDSToolStripMenuItem.Enabled = currTexture.isKnownFormat();
            hb1.ByteProvider = new DynamicByteProvider(rawResBuffer);
            MemoryStream m = new MemoryStream(rawResBuffer);

            m.Seek(0x20, 0);
            byte[] id = new byte[0x10];
            m.Read(id, 0, 0x10);
            exportChunkRawToolStripMenuItem.Enabled = false;
            string sid = Helpers.ByteArrayToHexString(id);

            foreach (ChunkInfo info in chunks)
            {
                if (info.id == sid)
                {
                    rawChunkBuffer = main.Host.getDataBySha1(info.sha1);
                    if (rawChunkBuffer == null)
                    {
                        return;
                    }
                    exportChunkRawToolStripMenuItem.Enabled = true;
                    hb2.ByteProvider = new DynamicByteProvider(rawChunkBuffer);
                    if (currTexture.isKnownFormat())
                    {
                        MakePreview();
                    }
                    else
                    {
                        pic1.Image = null;
                    }
                }
            }
        }
示例#2
0
        public void ProcessTexture()
        {
            currTexture = new TextureAsset(rawResBuffer);
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Texture Infos");
            sb.AppendLine("Name         : " + Path.GetFileName(currPath));
            sb.AppendLine("Type         : " + currTexture.formatType);
            sb.AppendLine("Format       : " + currTexture.formatID + " - 0x" + currTexture.formatID.ToString("X2") + (currTexture.isKnownFormat() ? " (supported)" : " (unsupported)"));
            int factor = (int)Math.Pow(2, currTexture.firstMip);

            sb.AppendLine("Size X       : " + currTexture.width + " (" + currTexture.width / factor + ")");
            sb.AppendLine("Size Y       : " + currTexture.height + " (" + currTexture.height / factor + ")");
            sb.AppendLine("Depth        : " + currTexture.depth);
            sb.AppendLine("Slice Count  : " + currTexture.sliceCount);
            sb.AppendLine("Mip Count    : " + currTexture.mipCount);
            sb.AppendLine("Mip Start    : " + currTexture.firstMip);
            rtb1.Text = sb.ToString();
        }
示例#3
0
        public void ProcessTexture()
        {
            currTexture = new TextureAsset(rawResBuffer);
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Texture Infos");
            sb.AppendLine("Name         : " + Path.GetFileName(currPath));
            sb.AppendLine("Type         : " + currTexture.formatType);
            sb.AppendLine("Format       : " + currTexture.formatID + " - 0x"
                          + currTexture.formatID.ToString("X2")
                          + (currTexture.isKnownFormat() ? " (supported)" : " (unsupported)")
                          + " (" + Enum.GetName(typeof(TextureAsset.FB_FORMAT), currTexture.formatID) + ")");
            int factor = (int)Math.Pow(2, currTexture.firstMip);

            sb.AppendLine("Size X       : " + currTexture.width + " (" + currTexture.width / factor + ")");
            sb.AppendLine("Size Y       : " + currTexture.height + " (" + currTexture.height / factor + ")");
            sb.AppendLine("Depth        : " + currTexture.depth);
            sb.AppendLine("Slice Count  : " + currTexture.sliceCount);
            sb.AppendLine("Mip Count    : " + currTexture.mipCount);
            sb.AppendLine("Mip Start    : " + currTexture.firstMip);
            sb.AppendLine("Mip 1 Offset : 0x" + currTexture.firstMipOffset.ToString("X8"));
            sb.AppendLine("Mip 2 Offset : 0x" + currTexture.secondMipOffset.ToString("X8"));
            sb.AppendLine("Mip Sizes    : ");
            factor = 1;
            uint sum = 0;

            foreach (uint size in currTexture.mipDataSizes)
            {
                sb.Append(" -> " + currTexture.width / factor + "x" + currTexture.height / factor + " = ");
                sb.AppendLine("0x" + size.ToString("X") + " bytes");
                factor <<= 1;
                sum     += size;
            }
            sb.AppendLine(" = 0x" + sum.ToString("X") + " bytes");
            rtb1.Text = sb.ToString();
        }