private void PreviewTex(ZipReader.ZipEntryFull ent, bool dds) { try { Bitmap img; if (dds) { byte[] data = ent.Extract(true); if (data == null) { throw new NullReferenceException("Data returned was null"); } DDSPreview ddsimg = new DDSPreview(data); //img = DDSImage.ToBitmap(ddsimg.GetMipData(), ddsimg.Format, (int)ddsimg.Width, (int)ddsimg.Height); img = ddsimg.ToBitmap(); } else { ent.Extract(false, "preview.tga"); img = new TargaImage("preview.tga").Image; File.Delete("preview.tga"); } if (pictureBox1.Image != null) { pictureBox1.Image.Dispose(); } if (_resize) { pictureBox1.Image = resizeImage(img, new System.Drawing.Size(512, 512)); } else { pictureBox1.Image = img; } pictureBox1.Visible = true; pictureBox1.Refresh(); } catch (Exception exc) { MessageBox.Show("An error occurred: " + exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void extractAllToolStripMenuItem_Click(object sender, EventArgs e) { FolderBrowserDialog fold = new FolderBrowserDialog(); fold.Description = "Select the directory to save the files to"; if (fold.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } for (int i = 0; i < _tpf.GetNumEntries(); i++) { ZipReader.ZipEntryFull ent = _tpf.GetEntry(i); ent.Extract(false, Path.Combine(fold.SelectedPath, ent.Filename)); } }
private void extractSelectedToolStripMenuItem_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex < 0) { return; } ZipReader.ZipEntryFull ent = _tpf.GetEntry(listBox1.SelectedIndex); SaveFileDialog saver = new SaveFileDialog(); saver.Title = "Enter the filename to save the extracted file to"; saver.FileName = ent.Filename; if (saver.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } ent.Extract(false, saver.FileName); }
private void PreviewDef(ZipReader.ZipEntryFull ent) { try { byte[] data = ent.Extract(true); if (data == null) { throw new NullReferenceException("Data returned was null"); } pictureBox1.Visible = false; char[] chars = new char[data.Length]; for (int i = 0; i < data.Length; i++) { chars[i] = (char)data[i]; } rtb1.Text = "Texmod.def contents:\n\n" + new string(chars); } catch (Exception exc) { MessageBox.Show("An error occurred: " + exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }