private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (listView1.SelectedIndices.Count <= 0) { return; } if (pictureBox1.Image != null) { Bitmap temp = (Bitmap)pictureBox1.Image; pictureBox1.Image = null; temp.Dispose(); } isLocked = true; PIGImage image = datafile.Bitmaps[listView1.SelectedIndices[0]]; pictureBox1.Image = PiggyBitmapUtilities.GetBitmap(datafile, palette, listView1.SelectedIndices[0]); TransparentCheck.Checked = image.Transparent; SupertransparentCheck.Checked = image.SuperTransparent; NoLightingCheck.Checked = image.NoLighting; CompressCheckBox.Checked = image.RLECompressed; Color color = Color.FromArgb(palette.GetRGBAValue(image.AverageIndex)); ColorPreview.BackColor = color; pictureBox1.Refresh(); isLocked = false; }
//--------------------------------------------------------------------- // GAUGE UPDATORS //--------------------------------------------------------------------- private void GaugeProperty_TextChanged(object sender, EventArgs e) { if (isLocked) { return; } ushort value; TextBox textBox = (TextBox)sender; if (ushort.TryParse(textBox.Text, out value)) { switch (textBox.Tag) { case "1": datafile.Gauges[ElementNumber] = value; UpdatePictureBox(PiggyBitmapUtilities.GetBitmap(datafile.piggyFile, palette, value - 1), pbGagueLores); break; case "2": datafile.GaugesHires[ElementNumber] = value; UpdatePictureBox(PiggyBitmapUtilities.GetBitmap(datafile.piggyFile, palette, value - 1), pbGagueHires); break; } } }
private void ExportMenu_Click(object sender, EventArgs e) { saveFileDialog1.Filter = "PNG Files|*.png"; if (listView1.SelectedIndices.Count > 1) { saveFileDialog1.FileName = "ignored"; } else { saveFileDialog1.FileName = ImageFilename(listView1.SelectedIndices[0]);//listView1.Items[listView1.SelectedIndices[0]].Text; } if (saveFileDialog1.ShowDialog() == DialogResult.OK) { if (listView1.SelectedIndices.Count > 1) { string directory = Path.GetDirectoryName(saveFileDialog1.FileName); foreach (int index in listView1.SelectedIndices) { Bitmap img = PiggyBitmapUtilities.GetBitmap(datafile, palette, index); string newpath = directory + Path.DirectorySeparatorChar + ImageFilename(index) + ".png"; img.Save(newpath); img.Dispose(); } } else { if (saveFileDialog1.FileName != "") { Bitmap img = PiggyBitmapUtilities.GetBitmap(datafile, palette, listView1.SelectedIndices[0]); img.Save(saveFileDialog1.FileName); img.Dispose(); } } } }
public List <int> LoadPolymodelTextures(Polymodel model, Palette palette, PIGFile pigFile) { List <int> textureIDs = new List <int>(); Bitmap image; foreach (string textureName in model.TextureList) { image = PiggyBitmapUtilities.GetBitmap(pigFile, palette, textureName); textureIDs.Add(LoadTexture(image)); } return(textureIDs); }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (pictureBox1.Image != null) { Image image = pictureBox1.Image; pictureBox1.Image = null; image.Dispose(); } ListEntry entry = (ListEntry)listBox1.Items[listBox1.SelectedIndex]; Selection = entry.id; pictureBox1.Image = PiggyBitmapUtilities.GetBitmap(imageProvider, palette, entry.id); }
private void UpdateCockpitPanel(int num) { ushort cockpit = datafile.Cockpits[num]; txtCockpitID.Text = cockpit.ToString(); if (pbCockpit.Image != null) { Bitmap temp = (Bitmap)pbCockpit.Image; pbCockpit.Image = null; temp.Dispose(); } pbCockpit.Image = PiggyBitmapUtilities.GetBitmap(datafile.piggyFile, palette, cockpit); }
private void InsertMenu_Click(object sender, EventArgs e) { openFileDialog1.Multiselect = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { foreach (string name in openFileDialog1.FileNames) { Bitmap img = new Bitmap(name); PIGImage bitmap = PiggyBitmapUtilities.CreatePIGImage(img, palette, Path.GetFileName(name).Substring(0, Math.Min(Path.GetFileName(name).Length, 8))); datafile.Bitmaps.Add(bitmap); ListViewItem lvi = GeneratePiggyEntry(datafile.Bitmaps.Count - 1); listView1.Items.Add(lvi); img.Dispose(); } } }
//--------------------------------------------------------------------- // SHARED UPDATORS //--------------------------------------------------------------------- private void RemapSingleImage_Click(object sender, EventArgs e) { Button button = (Button)sender; ImageSelector selector = new ImageSelector(piggyFile, palette, false); if (selector.ShowDialog() == DialogResult.OK) { isLocked = true; int value = selector.Selection; int shipvalue = 0; switch (button.Tag) { case "5": shipvalue = (int)nudShipTextures.Value - 2; datafile.multiplayerBitmaps[shipvalue * 2 + 1] = (ushort)(value); UpdateShipTextures(shipvalue); break; case "6": shipvalue = (int)nudShipTextures.Value - 2; datafile.multiplayerBitmaps[shipvalue * 2] = (ushort)(value); UpdateShipTextures(shipvalue); break; case "7": txtGagueLores.Text = (value).ToString(); datafile.Gauges[ElementNumber] = (ushort)(value); UpdatePictureBox(PiggyBitmapUtilities.GetBitmap(datafile.piggyFile, palette, value), pbGagueLores); break; case "8": txtGagueHires.Text = (value).ToString(); datafile.GaugesHires[ElementNumber] = (ushort)(value); UpdatePictureBox(PiggyBitmapUtilities.GetBitmap(datafile.piggyFile, palette, value), pbGagueHires); break; case "9": txtCockpitID.Text = (value).ToString(); datafile.Cockpits[ElementNumber] = (ushort)(value); UpdatePictureBox(PiggyBitmapUtilities.GetBitmap(datafile.piggyFile, palette, value), pbCockpit); break; } isLocked = false; } }
private void CalculateAverageButton_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 0) { return; } PIGImage image; for (int i = 0; i < listView1.SelectedItems.Count; i++) { image = datafile.Bitmaps[listView1.SelectedIndices[i]]; PiggyBitmapUtilities.SetAverageColor(image, palette); } image = datafile.Bitmaps[listView1.SelectedIndices[0]]; Color color = Color.FromArgb(palette.GetRGBAValue(image.AverageIndex)); ColorPreview.BackColor = color; pictureBox1.Refresh(); }
private void UpdateImage(int id) { if (pictureBox1.Image != null) { Bitmap temp = (Bitmap)pictureBox1.Image; pictureBox1.Image = null; temp.Dispose(); } PIGImage image = datafile.Bitmaps[listView1.SelectedIndices[0]]; pictureBox1.Image = PiggyBitmapUtilities.GetBitmap(datafile.Bitmaps[id], currentPalette); TransparentCheck.Checked = image.Transparent; SupertransparentCheck.Checked = image.SuperTransparent; NoLightingCheck.Checked = image.NoLighting; CompressCheckBox.Checked = image.RLECompressed; Color color = Color.FromArgb(currentPalette.GetRGBAValue(image.AverageIndex)); ColorPreview.BackColor = color; pictureBox1.Refresh(); }
public List <int> LoadPolymodelTextures(Polymodel model, PIGFile pigFile, Palette palette, EditorHAMFile hamFile) { List <int> textureIDs = new List <int>(); Bitmap image; EClip clip; foreach (string textureName in model.TextureList) { if (hamFile.EClipNameMapping.ContainsKey(textureName.ToLower())) { clip = hamFile.EClipNameMapping[textureName.ToLower()]; image = PiggyBitmapUtilities.GetBitmap(pigFile, palette, clip.Clip.Frames[0]); } else { image = PiggyBitmapUtilities.GetBitmap(pigFile, palette, textureName); } textureIDs.Add(LoadTexture(image)); } return(textureIDs); }
private void UpdateXLATPanel(int num) { ushort dst = datafile.BitmapXLATData[num]; txtXLATDest.Text = dst.ToString(); if (pbBitmapSrc.Image != null) { Bitmap temp = (Bitmap)pbBitmapSrc.Image; pbBitmapSrc.Image = null; temp.Dispose(); } pbBitmapSrc.Image = PiggyBitmapUtilities.GetBitmap(datafile.piggyFile, palette, num); if (pbBitmapDest.Image != null) { Bitmap temp = (Bitmap)pbBitmapDest.Image; pbBitmapDest.Image = null; temp.Dispose(); } pbBitmapDest.Image = PiggyBitmapUtilities.GetBitmap(datafile.piggyFile, palette, dst); }
public void UpdateGaguePanel(int num) { ushort gague = datafile.Gauges[num]; ushort hiresgague = datafile.GaugesHires[num]; txtGagueLores.Text = gague.ToString(); txtGagueHires.Text = hiresgague.ToString(); if (pbGagueLores.Image != null) { Bitmap temp = (Bitmap)pbGagueLores.Image; pbGagueLores.Image = null; temp.Dispose(); } pbGagueLores.Image = PiggyBitmapUtilities.GetBitmap(datafile.piggyFile, palette, gague); if (pbGagueHires.Image != null) { Bitmap temp = (Bitmap)pbGagueHires.Image; pbGagueHires.Image = null; temp.Dispose(); } pbGagueHires.Image = PiggyBitmapUtilities.GetBitmap(datafile.piggyFile, palette, hiresgague); }
private void UpdateShipTextures(int id) { UpdatePictureBox(PiggyBitmapUtilities.GetBitmap(datafile.piggyFile, palette, datafile.multiplayerBitmaps[id * 2]), pbWeaponTexture); UpdatePictureBox(PiggyBitmapUtilities.GetBitmap(datafile.piggyFile, palette, datafile.multiplayerBitmaps[id * 2 + 1]), pbWingTex); }