private void ConvertCurrentP1IToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "PNG (*.png)|*.png"; saveFileDialog.DefaultExt = "png"; saveFileDialog.Title = "Convert current P1I"; saveFileDialog.SupportMultiDottedExtensions = true; saveFileDialog.ShowHelp = false; saveFileDialog.OverwritePrompt = true; saveFileDialog.AddExtension = true; saveFileDialog.RestoreDirectory = true; saveFileDialog.FileName = Path.GetFileName(currentMIB.GetFileName()) + ".png"; DialogResult result = saveFileDialog.ShowDialog(); if (result == DialogResult.OK || result == DialogResult.Yes) { string saveFileName = saveFileDialog.FileName; if (!saveFileName.ToLower().EndsWith(".png")) { saveFileName += ".png"; } currentP1I.GetImage().Save(saveFileName, System.Drawing.Imaging.ImageFormat.Png); MessageBox.Show("Converted current P1I."); } }
private void BatchConvertP1IToolStripMenuItem_Click(object sender, EventArgs e) { CommonOpenFileDialog folderBrowserDialog = new CommonOpenFileDialog(); folderBrowserDialog.IsFolderPicker = true; folderBrowserDialog.RestoreDirectory = true; folderBrowserDialog.Title = "Open folder for batch P1I processing"; var result = folderBrowserDialog.ShowDialog(); if (result == CommonFileDialogResult.Ok) { int exportCount = 0; string[] workFiles = Directory.GetFiles(folderBrowserDialog.FileName); foreach (string filePath in workFiles) { if (filePath.ToLower().EndsWith(".p1i")) { currentP1I = new P1IFile(filePath); if (currentP1I.IsValid() && currentP1I.GetPaletteFile().IsValid()) { currentP1I.Render(); } string savePath = filePath + ".png"; currentP1I.GetImage().Save(savePath, System.Drawing.Imaging.ImageFormat.Png); exportCount++; } } MessageBox.Show($"Converted {exportCount} files."); } }
private void OpenP1IFileToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "P1I texture file (*.p1i)|*.p1i"; openFileDialog.RestoreDirectory = true; openFileDialog.ShowHelp = false; openFileDialog.Multiselect = false; openFileDialog.Title = "Open Texture"; DialogResult result = openFileDialog.ShowDialog(); if (result == DialogResult.OK || result == DialogResult.Yes) { RefreshDefault(); currentP1I = new P1IFile(openFileDialog.FileName); if (currentP1I.IsValid() && currentP1I.GetPaletteFile().IsValid()) { currentP1I.Render(); } attributeTextBox.Text = $"Texture file: {currentP1I.GetFileName()}\r\n\r\nPalette file: {currentP1I.GetPaletteFile().GetFileName()}\r\n\r\nBits per pixel: {currentP1I.GetBPP()}bpp\r\n\r\nWidth: {currentP1I.GetWidth()}px\r\n\r\nHeight: {currentP1I.GetHeight()}px"; texturePicBox.Image = currentP1I.GetImage(); convertCurrentP1IToolStripMenuItem.Enabled = true; closeFileToolStripMenuItem.Enabled = true; } }