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