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) { FTEX ftex = new FTEX(); ftex.ReplaceTexture(ofd.FileName, Format, 1, 0, SupportedFormats, true, true, false); if (ftex.texture != null) { image.BCLIMFormat = ConvertFormatGenericToBflim(ftex.Format); image.Height = (ushort)ftex.texture.Height; image.Width = (ushort)ftex.texture.Width; Format = GetFormat(image.BCLIMFormat); Width = image.Width; Height = image.Height; ImageData = ftex.texture.Data; UpdateForm(); } } }
public void LoadDDS(string FileName, byte[] FileData = null) { TexName = STGenericTexture.SetNameFromPath(FileName); DDS dds = new DDS(); if (FileData != null) { dds.Load(new FileReader(new MemoryStream(FileData))); } else { dds.Load(new FileReader(FileName)); } MipCount = dds.header.mipmapCount; TexWidth = dds.header.width; TexHeight = dds.header.height; arrayLength = 1; if (dds.header.caps2 == (uint)DDS.DDSCAPS2.CUBEMAP_ALLFACES) { arrayLength = 6; } DataBlockOutput.Add(dds.bdata); RedComp = dds.RedChannel; GreenComp = dds.GreenChannel; BlueComp = dds.BlueChannel; AlphaComp = dds.AlphaChannel; Format = (GX2.GX2SurfaceFormat)FTEX.ConvertToGx2Format(dds.Format);; }
private void AddTextureFTEX(BFRESGroupNode ftexCont) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = FileFilters.FTEX; ofd.Multiselect = true; if (ofd.ShowDialog() == DialogResult.OK) { string ResourceName = Path.GetFileNameWithoutExtension(ofd.FileName); FTEX ftex = new FTEX(); ftex.texture = new ResU.Texture(); ftex.Text = ResourceName; ftex.Replace(ofd.FileName); if (ftex.IsEdited) { ftexCont.AddNode(ftex); } else { ftex.Unload(); } listView1.Items.Add(ftex.Text, ftex.Text, 0); int lastItem = listView1.Items.Count - 1; listView1.Items[lastItem].Selected = true; listView1.Select(); } }
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0) { uint bpp = GetBytesPerPixel(Format); GTX.GX2Surface surf = new GTX.GX2Surface(); surf.bpp = bpp; surf.height = image.Height; surf.width = image.Width; surf.aa = (uint)GTX.GX2AAMode.GX2_AA_MODE_1X; surf.alignment = image.Alignment; surf.depth = 1; surf.dim = (uint)GTX.GX2SurfaceDimension.DIM_2D; surf.format = (uint)FTEX.ConvertToGx2Format(Format); surf.use = (uint)GTX.GX2SurfaceUse.USE_COLOR_BUFFER; surf.pitch = 0; surf.data = ImageData; surf.numMips = 1; surf.mipOffset = new uint[0]; surf.mipData = ImageData; surf.tileMode = (uint)GTX.GX2TileMode.MODE_2D_TILED_THIN1; surf.swizzle = image.swizzle; surf.numArray = 1; var surfaces = GTX.Decode(surf); return(surfaces[ArrayLevel][MipLevel]); }
public void SetupSettings() { if (SelectedTexSettings.Format == GTX.GX2SurfaceFormat.INVALID) { return; } if (formatComboBox.SelectedItem is GTX.GX2SurfaceFormat) { SelectedTexSettings.Format = (GTX.GX2SurfaceFormat)formatComboBox.SelectedItem; listViewCustom1.SelectedItems[0].SubItems[1].Text = SelectedTexSettings.Format.ToString(); } try { Bitmap bitmap = Switch_Toolbox.Library.Imaging.GetLoadingImage(); Thread = new Thread((ThreadStart)(() => { pictureBox1.Image = bitmap; SelectedTexSettings.Compress(); bitmap = FTEX.DecodeBlock(SelectedTexSettings.DataBlockOutput[0], SelectedTexSettings. TexWidth, SelectedTexSettings.TexHeight, (Syroot.NintenTools.Bfres.GX2.GX2SurfaceFormat)SelectedTexSettings.Format); pictureBox1.Image = bitmap; })); Thread.Start(); } catch (Exception ex) { throw new Exception(ex.ToString()); } }
public override void Replace(string FileName) { int size = data.Length; FTEX ftex = new FTEX(); ftex.ReplaceTexture(FileName, Format, MipCount, 0, SupportedFormats, true, true, true); if (ftex.texture != null) { byte[] ImageData = ftex.texture.Data; if (ftex.texture.MipData != null) { ImageData = Utils.CombineByteArray(ftex.texture.Data, ftex.texture.MipData); } // if (ImageData.Length != size) // MessageBox.Show($"Image size does not match! Make sure mip map count, format, height and width are all the same! Original Size {size} Import {ImageData.Length}", ); Swizzle = (byte)ftex.texture.Swizzle; byte[] NewData = new byte[size]; Array.Copy(ImageData, 0, NewData, 0, size); data = NewData; UpdateEditor(); } }
public byte[] GenerateMips(int SurfaceLevel = 0) { Bitmap Image = BitmapExtension.GetBitmap(DecompressedData[SurfaceLevel], (int)TexWidth, (int)TexHeight); List <byte[]> mipmaps = new List <byte[]>(); mipmaps.Add(FTEX.CompressBlock(DecompressedData[SurfaceLevel], (int)TexWidth, (int)TexHeight, Format)); //while (Image.Width / 2 > 0 && Image.Height / 2 > 0) // for (int mipLevel = 0; mipLevel < MipCount; mipLevel++) int width = Image.Width; int height = Image.Height; for (int mipLevel = 0; mipLevel < MipCount; mipLevel++) { if (Image.Width != 1) { width = Image.Width / 2; } if (Image.Height != 1) { height = Image.Height / 2; } Image = BitmapExtension.Resize(Image, width, height); mipmaps.Add(FTEX.CompressBlock(BitmapExtension.ImageToByte(Image), Image.Width, Image.Height, Format)); } Image.Dispose(); return(Utils.CombineByteArray(mipmaps.ToArray())); }
public override void Replace(string FileName) { uint swizzle = (image.Swizzle >> 8) & 7; FTEX ftex = new FTEX(); ftex.ReplaceTexture(FileName, Format, 1, swizzle, SupportedFormats, true, true, true, false); if (ftex.texture != null) { image.Swizzle = ftex.texture.Swizzle; image.BflimFormat = FormatsWiiU.FirstOrDefault(x => x.Value == ftex.Format).Key; image.Height = (ushort)ftex.texture.Height; image.Width = (ushort)ftex.texture.Width; if (ftex.UseBc4Alpha) { image.BflimFormat = 16; } Format = FormatsWiiU[image.BflimFormat]; Width = image.Width; Height = image.Height; ImageData = ftex.texture.Data; LoadComponents(Format, ftex.UseBc4Alpha); UpdateForm(); } }
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0) { if (image.Is3DS) { PlatformSwizzle = PlatformSwizzle.Platform_3DS; return(ImageData); } else { uint bpp = GetBytesPerPixel(Format); GX2.GX2Surface surf = new GX2.GX2Surface(); surf.bpp = bpp; surf.height = image.Height; surf.width = image.Width; surf.aa = (uint)GX2.GX2AAMode.GX2_AA_MODE_1X; surf.alignment = image.Alignment; surf.depth = 1; surf.dim = (uint)GX2.GX2SurfaceDimension.DIM_2D; surf.format = (uint)FTEX.ConvertToGx2Format(Format); surf.use = (uint)GX2.GX2SurfaceUse.USE_COLOR_BUFFER; surf.pitch = 0; surf.data = ImageData; surf.numMips = 1; surf.mipOffset = new uint[0]; surf.mipData = ImageData; surf.tileMode = (uint)GX2.GX2TileMode.MODE_2D_TILED_THIN1; surf.swizzle = image.Swizzle; surf.numArray = 1; return(GX2.Decode(surf, ArrayLevel, MipLevel)); } }
public void Compress() { DataBlockOutput.Clear(); foreach (var surface in DecompressedData) { DataBlockOutput.Add(FTEX.CompressBlock(surface, (int)TexWidth, (int)TexHeight, Format)); } }
public void LoadProperty(FTEX tex) { CurMipDisplayLevel = 0; CurArrayDisplayLevel = 0; textureData = tex; propertyGrid1.PropertySort = PropertySort.Categorized; UpdateMipDisplay(); }
public void Compress() { DataBlockOutput.Clear(); foreach (var surface in DecompressedData) { DataBlockOutput.Add(FTEX.CompressBlock(surface, (int)TexWidth, (int)TexHeight, FTEX.ConvertFromGx2Format((GX2SurfaceFormat)Format), alphaRef)); } }
public void SetupSettings(GTXImporterSettings setting) { if (setting.Format == GX2.GX2SurfaceFormat.INVALID || SelectedIndex == -1) { return; } if (Thread != null && Thread.IsAlive) { Thread.Abort(); } if (formatComboBox.SelectedItem is GX2.GX2SurfaceFormat) { setting.Format = (GX2.GX2SurfaceFormat)formatComboBox.SelectedItem; listViewCustom1.Items[SelectedIndex].SubItems[1].Text = setting.Format.ToString(); } HeightLabel.Text = $"Height: {setting.TexHeight}"; WidthLabel.Text = $"Width: {setting.TexWidth}"; Bitmap bitmap = Toolbox.Library.Imaging.GetLoadingImage(); pictureBox1.Image = bitmap; Thread = new Thread((ThreadStart)(() => { setting.IsFinishedCompressing = false; ToggleOkButton(false); var mips = setting.GenerateMipList(); setting.DataBlockOutput.Clear(); setting.DataBlockOutput.Add(Utils.CombineByteArray(mips.ToArray())); ToggleOkButton(true); setting.Compress(); bitmap = FTEX.DecodeBlockGetBitmap(mips[0], setting. TexWidth, setting.TexHeight, FTEX.ConvertFromGx2Format( (Syroot.NintenTools.Bfres.GX2.GX2SurfaceFormat)setting.Format), new byte[0]); if (pictureBox1.InvokeRequired) { pictureBox1.Invoke((MethodInvoker) delegate { pictureBox1.Image = bitmap; pictureBox1.Refresh(); int size = Utils.GetSizeInBytes(mips); dataSizeLbl.Text = $"Data Size: {STMath.GetFileSize(size, 5)}"; }); } mips.Clear(); })); Thread.Start(); }
public void LoadBitMap(Image Image, string FileName) { DecompressedData.Clear(); TexName = Path.GetFileNameWithoutExtension(FileName); Format = (GTX.GX2SurfaceFormat)FTEX.ConvertToGx2Format(Runtime.PreferredTexFormat); GenerateMipmaps = true; LoadImage(new Bitmap(Image)); }
public override void SetImageData(Bitmap bitmap, int ArrayLevel) { if (bitmap == null) { return; //Image is likely disposed and not needed to be applied } RedChannel = SetChannel(surface.compSel[0]); GreenChannel = SetChannel(surface.compSel[1]); BlueChannel = SetChannel(surface.compSel[2]); AlphaChannel = SetChannel(surface.compSel[3]); surface.format = (uint)FTEX.ConvertToGx2Format(Format); surface.width = (uint)bitmap.Width; surface.height = (uint)bitmap.Height; if (MipCount != 1) { MipCount = GenerateMipCount(bitmap.Width, bitmap.Height); if (MipCount == 0) { MipCount = 1; } } surface.numMips = MipCount; surface.mipOffset = new uint[MipCount]; try { //Create image block from bitmap first var data = GenerateMipsAndCompress(bitmap, MipCount, Format); //Swizzle and create surface var NewSurface = GX2.CreateGx2Texture(data, Text, (uint)surface.tileMode, (uint)surface.aa, (uint)surface.width, (uint)surface.height, (uint)surface.depth, (uint)surface.format, (uint)surface.swizzle, (uint)surface.dim, (uint)surface.numMips ); ApplySurface(NewSurface); IsEdited = true; LoadOpenGLTexture(); LibraryGUI.Instance.UpdateViewport(); } catch (Exception ex) { STErrorDialog.Show("Failed to swizzle and compress image " + Text, "Error", ex.ToString()); } }
private static bool BindFTEX(BFRESGroupNode ftexContainer, MatTexture tex, SF.Shader shader, string activeTex) { FTEX ftex = (FTEX)ftexContainer.ResourceNodes[activeTex]; if (ftex.RenderableTex == null || !ftex.RenderableTex.GLInitialized) { ftex.LoadOpenGLTexture(); } BindGLTexture(tex, shader, ftex); return(ftex.RenderableTex.GLInitialized); }
private void AddFTEXTextures(ResU.ResFile resFile) { FTEXContainer ftexContainer = new FTEXContainer(); Nodes.Add(ftexContainer); foreach (ResU.Texture tex in resFile.Textures.Values) { string TextureName = tex.Name; FTEX texture = new FTEX(); ftexContainer.Nodes.Add(texture); texture.Read(tex); ftexContainer.Textures.Add(texture.Text, texture); } PluginRuntime.ftexContainers.Add(ftexContainer); }
public override void SetImageData(System.Drawing.Bitmap bitmap, int ArrayLevel) { if (bitmap == null || image == null) { return; //Image is likely disposed and not needed to be applied } MipCount = 1; var Gx2Format = FTEX.ConvertToGx2Format(Format); uint swizzle = (image.Swizzle >> 8) & 7; try { //Create image block from bitmap first var data = GenerateMipsAndCompress(bitmap, MipCount, Format); //Swizzle and create surface var surface = GX2.CreateGx2Texture(data, Text, (uint)image.TileMode, (uint)0, (uint)image.Width, (uint)image.Height, (uint)1, (uint)Gx2Format, (uint)swizzle, (uint)1, (uint)MipCount ); image.Swizzle = surface.swizzle; image.BflimFormat = FormatsWiiU.FirstOrDefault(x => x.Value == Format).Key; image.Height = (ushort)surface.height; image.Width = (ushort)surface.width; Width = image.Width; Height = image.Height; ImageData = surface.data; IsEdited = true; LoadOpenGLTexture(); LibraryGUI.UpdateViewport(); } catch (Exception ex) { STErrorDialog.Show("Failed to swizzle and compress image " + Text, "Error", ex.ToString()); } }
private void DisplayTexture(FTEX texData) { if (Thread != null && Thread.IsAlive) { Thread.Abort(); } Thread = new Thread((ThreadStart)(() => { pictureBoxCustom1.Image = Switch_Toolbox.Library.Imaging.GetLoadingImage(); pictureBoxCustom1.Image = texData.GetBitmap(); // texSizeMipsLabel.Text = $"Width = {pictureBoxCustom1.Image.Width} Height = {pictureBoxCustom1.Image.Height}"; })); Thread.Start(); }
public void LoadSupportedFormats(TEX_FORMAT[] Formats) { formatComboBox.Items.Clear(); foreach (TEX_FORMAT format in Formats) { var Gx2Format = (GX2.GX2SurfaceFormat)FTEX.ConvertToGx2Format(format); formatComboBox.Items.Add(Gx2Format); } var Gx2DefaultFormat = (GX2.GX2SurfaceFormat)FTEX.ConvertToGx2Format(Runtime.PreferredTexFormat); if (formatComboBox.Items.Contains(Gx2DefaultFormat)) { formatComboBox.SelectedItem = Gx2DefaultFormat; } }
public static int BindTexture(MatTexture tex, bool IsWiiU) { GL.ActiveTexture(TextureUnit.Texture0 + tex.textureUnit + 1); // GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.Id); string activeTex = tex.Name; if (tex.animatedTexName != "") { activeTex = tex.animatedTexName; } if (IsWiiU) { foreach (var ftexContainer in PluginRuntime.ftexContainers) { if (ftexContainer.ResourceNodes.ContainsKey(activeTex)) { FTEX ftex = (FTEX)ftexContainer.ResourceNodes[activeTex]; if (ftex.RenderableTex == null || !ftex.RenderableTex.GLInitialized) { ftex.LoadOpenGLTexture(); } BindGLTexture(tex, ftex.RenderableTex.TexID); } } } else { foreach (var bntx in PluginRuntime.bntxContainers) { if (bntx.Textures.ContainsKey(activeTex)) { if (bntx.Textures[activeTex].RenderableTex == null || !bntx.Textures[activeTex].RenderableTex.GLInitialized) { bntx.Textures[activeTex].LoadOpenGLTexture(); } BindGLTexture(tex, bntx.Textures[activeTex].RenderableTex.TexID); } } } return(tex.textureUnit + 1); }
public override void Replace(string FileName) { FTEX ftex = new FTEX(); ftex.ReplaceTexture(FileName, Format); if (ftex.texture != null) { surface.swizzle = ftex.texture.Swizzle; surface.tileMode = (uint)ftex.texture.TileMode; surface.format = (uint)ftex.texture.Format; surface.aa = (uint)ftex.texture.AAMode; surface.use = (uint)ftex.texture.Use; surface.alignment = (uint)ftex.texture.Alignment; surface.dim = (uint)ftex.texture.Dim; surface.width = (uint)ftex.texture.Width; surface.height = (uint)ftex.texture.Height; surface.depth = (uint)ftex.texture.Depth; surface.numMips = (uint)ftex.texture.MipCount; surface.imageSize = (uint)ftex.texture.Data.Length; surface.mipSize = (uint)ftex.texture.MipData.Length; surface.data = ftex.texture.Data; surface.mipData = ftex.texture.MipData; surface.mipOffset = ftex.texture.MipOffsets; surface.firstMip = ftex.texture.ViewMipFirst; surface.firstSlice = 0; surface.numSlices = ftex.texture.ArrayLength; surface.imageCount = ftex.texture.MipCount; surface.pitch = ftex.texture.Pitch; surface.texRegs = GX2.CreateRegisters(surface); SetChannelComponents(); Format = FTEX.ConvertFromGx2Format((Syroot.NintenTools.Bfres.GX2.GX2SurfaceFormat)surface.format); Width = surface.width; Height = surface.height; MipCount = surface.numMips; ArrayCount = surface.depth; ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase)); if (editor != null) { UpdateEditor(); } } }
public void SetupSettings() { if (SelectedTexSettings.Format == GX2.GX2SurfaceFormat.INVALID || SelectedIndex == -1) { return; } if (Thread != null && Thread.IsAlive) { Thread.Abort(); } if (formatComboBox.SelectedItem is GX2.GX2SurfaceFormat) { SelectedTexSettings.Format = (GX2.GX2SurfaceFormat)formatComboBox.SelectedItem; listViewCustom1.Items[SelectedIndex].SubItems[1].Text = SelectedTexSettings.Format.ToString(); } HeightLabel.Text = $"Height: {SelectedTexSettings.TexHeight}"; WidthLabel.Text = $"Width: {SelectedTexSettings.TexWidth}"; Bitmap bitmap = Switch_Toolbox.Library.Imaging.GetLoadingImage(); Thread = new Thread((ThreadStart)(() => { SelectedTexSettings.IsFinishedCompressing = false; ToggleOkButton(false); var mips = SelectedTexSettings.GenerateMipList(); SelectedTexSettings.DataBlockOutput.Clear(); SelectedTexSettings.DataBlockOutput.Add(Utils.CombineByteArray(mips.ToArray())); ToggleOkButton(true); pictureBox1.Image = bitmap; SelectedTexSettings.Compress(); bitmap = FTEX.DecodeBlockGetBitmap(mips[0], SelectedTexSettings. TexWidth, SelectedTexSettings.TexHeight, FTEX.ConvertFromGx2Format( (Syroot.NintenTools.Bfres.GX2.GX2SurfaceFormat)SelectedTexSettings.Format)); pictureBox1.Image = bitmap; })); Thread.Start(); }
public void UpdateEditor() { ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase)); if (editor == null) { editor = new ImageEditorBase(); editor.Dock = DockStyle.Fill; LibraryGUI.LoadEditor(editor); } editor.Text = Text; var tex = FTEX.FromGx2Surface(surface, Text); tex.MipCount = MipCount; editor.LoadProperties(tex); editor.LoadImage(this); }
public static BFLIM CreateNewFromImage() { BFLIM bflim = new BFLIM(); bflim.CanSave = true; bflim.IFileInfo = new IFileInfo(); bflim.header = new Header(); OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = false; ofd.Filter = FileFilters.GTX; if (ofd.ShowDialog() != DialogResult.OK) { return(null); } FTEX ftex = new FTEX(); ftex.ReplaceTexture(ofd.FileName, TEX_FORMAT.BC3_UNORM_SRGB, 1, 0, bflim.SupportedFormats, true, false, true, false); if (ftex.texture != null) { bflim.Text = $"{Path.GetFileNameWithoutExtension(ofd.FileName)}.bflim"; bflim.image = new Image(); bflim.image.Swizzle = (byte)ftex.texture.Swizzle; bflim.image.BflimFormat = FormatsWiiU.FirstOrDefault(x => x.Value == ftex.Format).Key; if (ftex.UseBc4Alpha) { bflim.image.BflimFormat = 16; } bflim.image.Height = (ushort)ftex.texture.Height; bflim.image.Width = (ushort)ftex.texture.Width; bflim.Format = FormatsWiiU[bflim.image.BflimFormat]; bflim.Width = bflim.image.Width; bflim.Height = bflim.image.Height; bflim.ImageData = ftex.texture.Data; bflim.LoadComponents(bflim.Format, ftex.UseBc4Alpha); } return(bflim); }
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) { FTEX ftex = new FTEX(); ftex.Replace(ofd.FileName); } }
public override void Replace(string FileName) { FTEX ftex = new FTEX(); ftex.ReplaceTexture(FileName, Format, 1, SupportedFormats, true, true, false); if (ftex.texture != null) { image.Swizzle = (byte)ftex.texture.Swizzle; image.BflimFormat = ConvertFormatGenericToBflim(ftex.Format); image.Height = (ushort)ftex.texture.Height; image.Width = (ushort)ftex.texture.Width; Format = GetFormat(image.BflimFormat); Width = image.Width; Height = image.Height; ImageData = ftex.texture.Data; UpdateForm(); } }
public void CreateNew(object sender, EventArgs args) { BFLIM bflim = new BFLIM(); bflim.CanSave = true; bflim.IFileInfo = new IFileInfo(); bflim.header = new Header(); OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = false; ofd.Filter = FileFilters.GTX; if (ofd.ShowDialog() != DialogResult.OK) { return; } FTEX ftex = new FTEX(); ftex.ReplaceTexture(ofd.FileName, TEX_FORMAT.BC3_UNORM_SRGB, 1, 0, bflim.SupportedFormats, false, true, false); if (ftex.texture != null) { bflim.Text = ftex.texture.Name; bflim.image = new Image(); bflim.image.Swizzle = (byte)ftex.texture.Swizzle; bflim.image.BflimFormat = FormatsWiiU.FirstOrDefault(x => x.Value == ftex.Format).Key; bflim.image.Height = (ushort)ftex.texture.Height; bflim.image.Width = (ushort)ftex.texture.Width; bflim.Format = FormatsWiiU[bflim.image.BflimFormat]; bflim.Width = bflim.image.Width; bflim.Height = bflim.image.Height; bflim.ImageData = ftex.texture.Data; var form = new GenericEditorForm(false, bflim.OpenForm()); LibraryGUI.CreateMdiWindow(form); bflim.UpdateForm(); } }
public void LoadBitMap(string FileName) { DecompressedData.Clear(); TexName = Path.GetFileNameWithoutExtension(FileName); Format = (GTX.GX2SurfaceFormat)FTEX.ConvertToGx2Format(Runtime.PreferredTexFormat); GenerateMipmaps = true; //If a texture is .tga, we need to convert it Bitmap Image = null; if (Utils.GetExtension(FileName) == ".tga") { Image = Paloma.TargaImage.LoadTargaImage(FileName); } else { Image = new Bitmap(FileName); } LoadImage(Image); }
public void SetupSettings() { if (SelectedTexSettings.Format == GTX.GX2SurfaceFormat.INVALID) { return; } if (Thread != null && Thread.IsAlive) { Thread.Abort(); } if (formatComboBox.SelectedItem is GTX.GX2SurfaceFormat) { SelectedTexSettings.Format = (GTX.GX2SurfaceFormat)formatComboBox.SelectedItem; listViewCustom1.SelectedItems[0].SubItems[1].Text = SelectedTexSettings.Format.ToString(); } HeightLabel.Text = $"Height: {SelectedTexSettings.TexHeight}"; WidthLabel.Text = $"Width: {SelectedTexSettings.TexWidth}"; Bitmap bitmap = Switch_Toolbox.Library.Imaging.GetLoadingImage(); Thread = new Thread((ThreadStart)(() => { pictureBox1.Image = bitmap; SelectedTexSettings.Compress(); bitmap = FTEX.DecodeBlockGetBitmap(SelectedTexSettings.DataBlockOutput[0], SelectedTexSettings. TexWidth, SelectedTexSettings.TexHeight, FTEX.ConvertFromGx2Format( (Syroot.NintenTools.Bfres.GX2.GX2SurfaceFormat)SelectedTexSettings.Format)); pictureBox1.Image = bitmap; })); Thread.Start(); }