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"); using (ImageEngineImage ddsimg = new ImageEngineImage(data)) img = ddsimg.GetGDIBitmap(true); } 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 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); } }