Example #1
0
            public override void Replace(string FileName)
            {
                var bntxFile = new BNTX();
                var tex      = new TextureData();

                tex.Replace(FileName, MipCount, 0, Format);

                //If it's null, the operation is cancelled
                if (tex.Texture == null)
                {
                    return;
                }

                var surfacesNew = tex.GetSurfaces();
                var surfaces    = GetSurfaces();

                ImageData = tex.Texture.TextureData[0][0];

                Width    = tex.Texture.Width;
                Height   = tex.Texture.Height;
                MipCount = tex.Texture.MipCount;

                Format    = tex.Format;
                XTXFormat = ConvertFromGenericFormat(tex.Format);

                MipOffsets = TegraX1Swizzle.GenerateMipSizes(tex.Format, tex.Width, tex.Height, tex.Depth, tex.ArrayCount, tex.MipCount, (uint)ImageData.Length)[0];

                surfacesNew.Clear();
                surfaces.Clear();

                UpdateEditor();
            }
Example #2
0
        public override void Replace(string FileName)
        {
            var bntxFile = new BNTX();
            var tex      = new TextureData();

            tex.Replace(FileName, MipCount, 0, Format);

            //If it's null, the operation is cancelled
            if (tex.Texture == null)
            {
                return;
            }

            var surfacesNew = tex.GetSurfaces();
            var surfaces    = GetSurfaces();

            if (LimitFileSize)
            {
                if (surfaces[0].mipmaps[0].Length != surfacesNew[0].mipmaps[0].Length)
                {
                    throw new Exception($"Image must be the same size! {surfaces[0].mipmaps[0].Length}");
                }

                if (mipSizes[0].Length != surfacesNew[0].mipmaps.Count)
                {
                    throw new Exception($"Mip map count must be the same! {mipSizes[0].Length}");
                }

                if (Width != tex.Texture.Width || Height != tex.Texture.Height)
                {
                    throw new Exception("Image size must be the same!");
                }

                ImageData = tex.Texture.TextureData[0][0];

                Width    = tex.Texture.Width;
                Height   = tex.Texture.Height;
                MipCount = tex.Texture.MipCount;
            }
            else
            {
                ImageData = tex.Texture.TextureData[0][0];

                Width    = tex.Texture.Width;
                Height   = tex.Texture.Height;
                MipCount = tex.Texture.MipCount;

                Format    = tex.Format;
                NutFormat = ConvertGenericToNutFormat(tex.Format);

                mipSizes = TegraX1Swizzle.GenerateMipSizes(tex.Format, tex.Width, tex.Height, tex.Depth, tex.ArrayCount, tex.MipCount, (uint)ImageData.Length);
            }

            surfacesNew.Clear();
            surfaces.Clear();

            UpdateEditor();
        }
Example #3
0
            public override void Replace(string FileName)
            {
                var tex = new TextureData();

                tex.Replace(FileName, MipCount, 0, Format);

                //If it's null, the operation is cancelled
                if (tex.Texture == null)
                {
                    return;
                }

                var surfacesNew = tex.GetSurfaces();
                var surfaces    = GetSurfaces();

                ImageData = tex.Texture.TextureData[0][0];

                Width           = tex.Texture.Width;
                Height          = tex.Texture.Height;
                MipCount        = tex.Texture.MipCount;
                TextureLayout1  = tex.Texture.textureLayout;
                TextureLayout2  = tex.Texture.textureLayout2;
                BlockHeightLog2 = tex.Texture.BlockHeightLog2;

                Format    = tex.Format;
                XTXFormat = ConvertFromGenericFormat(tex.Format);

                uint[] mips = TegraX1Swizzle.GenerateMipSizes(tex.Format, tex.Width, tex.Height, tex.Depth, tex.ArrayCount, tex.MipCount, (uint)ImageData.Length)[0];
                MipOffsets = new uint[17];

                for (int i = 0; i < mips.Length; i++)
                {
                    MipOffsets[i] = mips[i];
                }

                surfacesNew.Clear();
                surfaces.Clear();

                UpdateEditor();
            }
Example #4
0
        public override void Replace(string FileName)
        {
            var bntxFile = new BNTX();
            var tex      = new TextureData();

            tex.Replace(FileName, MipCount, 0, Format);

            //If it's null, the operation is cancelled
            if (tex.Texture == null)
            {
                return;
            }

            var surfacesNew = tex.GetSurfaces();
            var surfaces    = GetSurfaces();

            if (LimitFileSize)
            {
                if (surfaces[0].mipmaps[0].Length < surfacesNew[0].mipmaps[0].Length)
                {
                    if (surfaces[0].mipmaps[0].Length != surfacesNew[0].mipmaps[0].Length)
                    {
                        throw new Exception($"Image must be the same size! {surfaces[0].mipmaps[0].Length}");
                    }

                    if (mipSizes[0].Length != surfacesNew[0].mipmaps.Count)
                    {
                        throw new Exception($"Mip map count must be the same! {mipSizes[0].Length}");
                    }

                    if (Width != tex.Texture.Width || Height != tex.Texture.Height)
                    {
                        throw new Exception("Image size must be the same!");
                    }
                }

                Width    = tex.Texture.Width;
                Height   = tex.Texture.Height;
                MipCount = tex.Texture.MipCount;
            }
            else
            {
                Width      = tex.Texture.Width;
                Height     = tex.Texture.Height;
                MipCount   = tex.Texture.MipCount;
                ArrayCount = tex.Texture.ArrayLength;
                Depth      = tex.Texture.Depth;

                Format    = tex.Format;
                NutFormat = ConvertGenericToNutFormat(tex.Format);

                mipSizes = TegraX1Swizzle.GenerateMipSizes(tex.Format, tex.Width, tex.Height, tex.Depth, tex.ArrayCount, tex.MipCount, (uint)ImageData.Length);
            }

            List <byte[]> data = new List <byte[]>();

            foreach (var array in tex.Texture.TextureData)
            {
                data.Add(array[0]);
            }

            var output = Utils.CombineByteArray(data.ToArray());

            ImageData = SetImageData(output);

            data.Clear();
            surfacesNew.Clear();
            surfaces.Clear();

            UpdateEditor();
        }
        private void Replace(object sender, EventArgs args)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = FileFilters.NUTEXB;

            ofd.Multiselect = false;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                var bntxFile = new BNTX();
                var tex      = new TextureData();
                tex.Replace(ofd.FileName, MipCount, Format);

                //If it's null, the operation is cancelled
                if (tex.Texture == null)
                {
                    return;
                }

                var surfacesNew = tex.GetSurfaces();
                var surfaces    = GetSurfaces();

                if (LimitFileSize)
                {
                    if (surfaces[0].mipmaps[0].Length != surfacesNew[0].mipmaps[0].Length)
                    {
                        throw new Exception($"Image must be the same size! {surfaces[0].mipmaps[0].Length}");
                    }

                    if (mipSizes[0].Length != surfacesNew[0].mipmaps.Count)
                    {
                        throw new Exception($"Mip map count must be the same! {mipSizes[0].Length}");
                    }

                    if (Width != tex.Texture.Width || Height != tex.Texture.Height)
                    {
                        throw new Exception("Image size must be the same!");
                    }

                    ImageData = tex.Texture.TextureData[0][0];

                    Width    = tex.Texture.Width;
                    Height   = tex.Texture.Height;
                    MipCount = tex.Texture.MipCount;
                }
                else
                {
                    ImageData = tex.Texture.TextureData[0][0];

                    Width    = tex.Texture.Width;
                    Height   = tex.Texture.Height;
                    MipCount = tex.Texture.MipCount;

                    Format    = tex.Format;
                    NutFormat = ConvertGenericToNutFormat(tex.Format);

                    mipSizes = TegraX1Swizzle.GenerateMipSizes(tex.Format, tex.Width, tex.Height, tex.Depth, tex.ArrayCount, tex.MipCount, (uint)ImageData.Length);
                }

                surfacesNew.Clear();
                surfaces.Clear();

                UpdateEditor();
            }
        }
Example #6
0
        public string ArcOffset; //Temp for exporting in batch

        private void Replace(object sender, EventArgs args)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Supported Formats|*.dds; *.png;*.tga;*.jpg;*.tiff|" +
                         "Microsoft DDS |*.dds|" +
                         "Portable Network Graphics |*.png|" +
                         "Joint Photographic Experts Group |*.jpg|" +
                         "Bitmap Image |*.bmp|" +
                         "Tagged Image File Format |*.tiff|" +
                         "All files(*.*)|*.*";

            ofd.Multiselect = false;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                var bntxFile = new BNTX();
                var tex      = new TextureData();
                tex.Replace(ofd.FileName, MipCount, Format);

                //If it's null, the operation is cancelled
                if (tex.Texture == null)
                {
                    return;
                }

                var surfacesNew = tex.GetSurfaces();
                var surfaces    = GetSurfaces();

                if (LimitFileSize)
                {
                    if (surfaces[0].mipmaps[0].Length != surfacesNew[0].mipmaps[0].Length)
                    {
                        throw new Exception($"Image must be the same size! {surfaces[0].mipmaps[0].Length}");
                    }

                    if (mipSizes[0].Length != surfacesNew[0].mipmaps.Count)
                    {
                        throw new Exception($"Mip map count must be the same! {mipSizes[0].Length}");
                    }

                    if (Width != tex.Texture.Width || Height != tex.Texture.Height)
                    {
                        throw new Exception("Image size must be the same!");
                    }

                    ImageData = tex.Texture.TextureData[0][0];

                    Width    = tex.Texture.Width;
                    Height   = tex.Texture.Height;
                    MipCount = tex.Texture.MipCount;
                }
                else
                {
                    ImageData = tex.Texture.TextureData[0][0];

                    Width    = tex.Texture.Width;
                    Height   = tex.Texture.Height;
                    MipCount = tex.Texture.MipCount;

                    Format    = tex.Format;
                    NutFormat = ConvertGenericToNutFormat(tex.Format);

                    mipSizes = GenerateMipSizes();
                }

                surfacesNew.Clear();
                surfaces.Clear();

                UpdateEditor();
            }
        }