예제 #1
0
        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.");
            }
        }
예제 #2
0
        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;
            }
        }