KTXPlugin() { TextureContainer = new ITextureContainer[] { new CoreFileContainer() }; MipmapGenerators = new IMipmapGenerator[] { }; InternalPixelFormats = new IGLInteralPixelFormat[] { }; PixelFormats = new IGLPixelFormat[] { }; DataFormats = new IGLDataFormat[] { }; }
private void SaveTo(string path) { string ext = Path.GetExtension(path); ITextureContainer container = GetContainerFromExtension(ext); if (container != null) { TransformTextureBack(); container.Store(path, texture, genericTexture); } }
static ObjectTreeNode LoadTextureContainerFormat(ImageList imageList, ITextureContainer textureContainer) { IFileFormat fileFormat = (IFileFormat)textureContainer; ObjectTreeNode root = new ObjectTreeNode(fileFormat.FileInfo.FileName); root.Tag = fileFormat; root.ImageKey = "TextureContainer"; foreach (var tex in textureContainer.TextureList) { root.AddChild(LoadTextureFormat(tex)); } return(root); }
private void openToolStripMenuItem1_Click(object sender, EventArgs e) { OpenFileDialog ofdlg = new OpenFileDialog(); ofdlg.Filter = BuildFileContainerFilter(); if (ofdlg.ShowDialog() == DialogResult.OK) { string name = ofdlg.FileName; string ext = Path.GetExtension(name); ITextureContainer container = GetContainerFromExtension(ext); if (container != null) { DisplayTexture(name, container.Load(name)); } } }
CoreFormatsPlugin() { DataFormats = new IGLDataFormat[] { new CoreDataFormatBase(Values.GL_BYTE, 1, 1), new CoreDataFormatBase(Values.GL_UNSIGNED_BYTE, 1, 1), new CoreDataFormatBase(Values.GL_SHORT, 1, 2), new CoreDataFormatBase(Values.GL_UNSIGNED_SHORT, 1, 2), new CoreDataFormatBase(Values.GL_INT, 1, 4), new CoreDataFormatBase(Values.GL_UNSIGNED_INT, 1, 4), new CoreDataFormatBase(Values.GL_FLOAT, 1, 4), new CoreDataFormatBase(Values.GL_DOUBLE, 1, 8) }; PixelFormats = new IGLPixelFormat[] { new CorePixelFormatBase(Values.GL_RED, 1), new CorePixelFormatBase(Values.GL_RGB, 3), new CorePixelFormatBase(Values.GL_RGBA, 4), new CorePixelFormatSwapRG(Values.GL_BGR, 3), new CorePixelFormatSwapRG(Values.GL_BGRA, 4) }; InternalPixelFormats = new IGLInteralPixelFormat[] { new CoreInaternalPixelFormatBase(Values.GL_RED), new CoreInaternalPixelFormatBase(Values.GL_RGB), new CoreInaternalPixelFormatBase(Values.GL_R3_G3_B2), new CoreInaternalPixelFormatBase(Values.GL_RGB4), new CoreInaternalPixelFormatBase(Values.GL_RGB5), new CoreInaternalPixelFormatBase(Values.GL_RGB8), new CoreInaternalPixelFormatBase(Values.GL_RGB10), new CoreInaternalPixelFormatBase(Values.GL_RGB12), new CoreInaternalPixelFormatBase(Values.GL_RGB16), new CoreInaternalPixelFormatBase(Values.GL_RGBA), new CoreInaternalPixelFormatBase(Values.GL_RGBA2), new CoreInaternalPixelFormatBase(Values.GL_RGBA4), new CoreInaternalPixelFormatBase(Values.GL_RGB5_A1), new CoreInaternalPixelFormatBase(Values.GL_RGBA8), new CoreInaternalPixelFormatBase(Values.GL_RGB10_A2), new CoreInaternalPixelFormatBase(Values.GL_RGBA12), new CoreInaternalPixelFormatBase(Values.GL_RGBA16) }; MipmapGenerators = new IMipmapGenerator[] { }; TextureContainer = new ITextureContainer[] { }; }
private void ReloadTextureIcons(ITextureContainer textureContainer, List <ObjectTreeNode> children) { var fileName = ((IFileFormat)textureContainer).FileInfo.FilePath; var textureList = textureContainer.TextureList.ToList(); Thread Thread = new Thread((ThreadStart)(() => { for (int i = 0; i < textureList.Count; i++) { var image = textureList[i].GetBitmap(); if (image != null) { // uint checksum = Core.Hashes.ChecksumQuick.GetChecksum(image); // children[i].ImageKey = checksum.ToString(); children[i].ImageKey = fileName + textureList[i].Name; if (this.InvokeRequired) { this.Invoke((MethodInvoker) delegate { if (!this.imgList.Images.ContainsKey(children[i].ImageKey)) { this.imgList.Images.Add(children[i].ImageKey, image); } }); } else { if (!this.imgList.Images.ContainsKey(children[i].ImageKey)) { this.imgList.Images.Add(children[i].ImageKey, image); } } } } })); Thread.Start(); }
public void LoadGenericTextureIcons(ITextureContainer iconList) { treeViewCustom1.TextureIcons.Add(iconList); treeViewCustom1.ReloadTextureIcons(iconList); }
public void ReloadTextureIcons(ITextureContainer textureIconList) { if (!textureIconList.DisplayIcons) { return; } if (Thread != null && Thread.IsAlive) { Thread.Abort(); } this.BeginUpdate(); Thread = new Thread((ThreadStart)(() => { List <TreeNode> treeNodes = new List <TreeNode>(); List <Image> imageIcons = new List <Image>(); foreach (TreeNode node in textureIconList.TextureList) { if (node is STGenericTexture) { try { var image = ((STGenericTexture)node).GetBitmap(); if (image != null) { image = ((STGenericTexture)node).GetComponentBitmap(image); treeNodes.Add(node); imageIcons.Add(image); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } for (int i = 0; i < treeNodes.Count; i++) { AddImageOnThread(i, treeNodes[i]); } if (this.InvokeRequired) { this.Invoke((MethodInvoker) delegate { this.ImageList.Images.AddRange(imageIcons.ToArray()); }); } for (int i = 0; i < treeNodes.Count; i++) { imageIcons[i].Dispose(); } imageIcons.Clear(); treeNodes.Clear(); if (this.InvokeRequired) { this.Invoke((MethodInvoker) delegate { this.EndUpdate(); }); } })); Thread.Start(); }
static async Task ProcessTexturesAsync(TextureOptions options, ITextureContainer container) { string dir = options.InputFile + ".textures"; Directory.CreateDirectory(dir); Stream patchFile = Stream.Null; if (options.WritePatch && (options.Mode == ExtractionMode.INJC || options.Mode == ExtractionMode.INJD)) { patchFile = File.Create(options.InputFile + ".patch"); } // Start reading textures one by one for (int i = 0; i < container.TextureCount; i++) { using (var texture = await container.GetTextureAsync(i)) { switch (options.Mode) { case ExtractionMode.DUMP: try { string dumpPath = Path.Combine(dir, $"texture_{i}.bin"); WriteLine($"Found texture #{i}; Dumping to file..."); using (var stream = File.Create(dumpPath)) { await texture.CopyToStreamAsync(stream); } WriteLine($"Dumped to {dumpPath} successfully!", OutputImportance.Verbose); } catch (Exception) { WriteLine("Dump failed!!! This is a bug. Please notify the developers immediately with details about how the issue arose.", OutputImportance.Error); WriteLine("Create an issue on github: https://www.github.com/yodadude2003/NuXtractor", OutputImportance.Verbose); WriteLine("Write us an email: [email protected]", OutputImportance.Verbose); } break; case ExtractionMode.CONV: try { WriteLine($"Found texture #{i}; Converting to PNG..."); var image = await texture.ReadImageAsync(); string convPath = Path.Combine(dir, $"texture_{i}.png"); await image.SaveAsPngAsync(convPath); WriteLine($"Conversion successful! Wrote output to file: {convPath}", OutputImportance.Verbose); } catch (Exception) { WriteLine("Conversion failed! Moving on to next texture...", OutputImportance.Error); } break; case ExtractionMode.INJD: try { string injdPath = Path.Combine(dir, $"texture_{i}.bin"); if (File.Exists(injdPath)) { WriteLine($"Found replacement file {injdPath}; Injecting raw texture data..."); using (var stream = File.OpenRead(injdPath)) { await texture.CopyFromStreamAsync(stream); } await texture.WritePatchAsync(patchFile); WriteLine($"Injected texture #{i} successfully!", OutputImportance.Verbose); } } catch (Exception) { WriteLine("Injection failed!!! This is a bug. Please notify the developers immediately with details about how the issue arose.", OutputImportance.Error); WriteLine("Create an issue on github: https://www.github.com/yodadude2003/NuXtractor", OutputImportance.Verbose); WriteLine("Write us an email: [email protected]", OutputImportance.Verbose); } break; case ExtractionMode.INJC: try { string injcPath = Path.Combine(dir, $"texture_{i}.png"); if (File.Exists(injcPath)) { WriteLine($"Found replacement image {injcPath}; Converting & injecting texture..."); var image = await Image.LoadAsync <RgbaVector>(injcPath); await texture.WriteImageAsync(image); await texture.WritePatchAsync(patchFile); WriteLine($"Injected texture #{i} successfully!", OutputImportance.Verbose); } } catch (Exception) { WriteLine($"Failed to inject texture #{i}!", OutputImportance.Error); WriteLine("Create an issue on github: https://www.github.com/yodadude2003/NuXtractor", OutputImportance.Verbose); WriteLine("Write us an email: [email protected]", OutputImportance.Verbose); } break; } } } patchFile.Dispose(); }