Exemple #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();
            }
Exemple #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();
        }
Exemple #3
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.Filter = "Supported Formats|*.dds;" +
                         "Microsoft DDS |*.dds" +
                         "All files(*.*)|*.*";

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

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

                if (Surfaces[0].mipmaps.Count != tex.Surfaces[0].mipmaps.Count)
                {
                    throw new Exception("Map map count must be the same!");
                }

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

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

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

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

            ofd.Filter = "Supported Formats|*.bftex;*.dds; *.png;*.tga;*.jpg;*.tiff|" +
                         "Binary Texture |*.bftex|" +
                         "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)
            {
                SelectedTex.Replace(ofd.FileName);
            }
        }
Exemple #5
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();
            }
Exemple #6
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;
            }

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

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

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

            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);

            ImageData = SetImageData(output);

            data.Clear();
            UpdateEditor();
        }
Exemple #7
0
        public override void Replace(string FileName)
        {
            if (Runtime.NUTEXBSettings.IsSwizzled)
            {
                var tex = new TextureData();
                tex.Replace(FileName, MipCount, 0, Format);

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

                List <byte[]> data = new List <byte[]>();
                foreach (var array in tex.Texture.TextureData)
                {
                    data.Add(array[0]);
                }

                var output = CreateBuffer(data);

                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);

                ImageData = SetImageData(output);

                data.Clear();
            }
            else
            {
                GenericTextureImporterList     importer = new GenericTextureImporterList(SupportedFormats);
                GenericTextureImporterSettings settings = new GenericTextureImporterSettings();

                if (Utils.GetExtension(FileName) == ".dds" ||
                    Utils.GetExtension(FileName) == ".dds2")
                {
                    settings.LoadDDS(FileName);
                    importer.LoadSettings(new List <GenericTextureImporterSettings>()
                    {
                        settings,
                    });
                    ApplySettings(settings);
                    UpdateEditor();
                }
                else
                {
                    settings.LoadBitMap(FileName);
                    importer.LoadSettings(new List <GenericTextureImporterSettings>()
                    {
                        settings,
                    });

                    if (importer.ShowDialog() == DialogResult.OK)
                    {
                        if (settings.GenerateMipmaps && !settings.IsFinishedCompressing)
                        {
                            settings.DataBlockOutput.Clear();
                            settings.DataBlockOutput.Add(settings.GenerateMips(importer.CompressionMode, importer.MultiThreading));
                        }

                        ApplySettings(settings);
                        UpdateEditor();
                    }
                }
            }

            UpdateEditor();
        }
Exemple #8
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();
            }
        }
Exemple #10
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();
            }
        }