public void Open(Stream stream) { currentFile = TexFile.ReadFile(stream); using (MagickImage image = new MagickImage(currentFile.Data)) ReloadUI(image, currentFile.Format); }
private void exportToolStripMenuItem1_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog { Filter = "Texture file (*.tex)|*.tex|All Files (*.*)|*.*", Multiselect = true }; if (open.ShowDialog() != DialogResult.OK) { return; } foreach (string filename in open.FileNames) { using (FileStream fs = new FileStream(filename, FileMode.Open)) { TexFile file = TexFile.ReadFile(fs); string outputFilename; switch (file.Format) { case TextureFormat.ARGB32: outputFilename = Path.ChangeExtension(filename, ".png"); break; case TextureFormat.RGB24: outputFilename = Path.ChangeExtension(filename, ".jpeg"); break; default: case TextureFormat.DXT1: case TextureFormat.DXT5: outputFilename = Path.ChangeExtension(filename, ".dds"); break; } File.WriteAllBytes(outputFilename, file.Data); } } }