private void UpdateImages() { if (string.IsNullOrEmpty(SHPFile)) { return; } this.uC_ImageCanvas_Left.SetImage(CSHaPer.GetFrame(SHPFile, (int)this.numericUpDown_FrameLeft.Value, _Palette)); this.uC_ImageCanvas_Right.SetImage(CSHaPer.GetFrame(SHPFile, (int)this.numericUpDown_FrameRight.Value, _Palette)); }
void numericUpDown_FrameRight_ValueChanged(object sender, EventArgs e) { if (string.IsNullOrEmpty(SHPFile)) { return; } if (this.numericUpDown_FrameRight.Focused) { this.uC_ImageCanvas_Right.SetImage(CSHaPer.GetFrame(SHPFile, (int)this.numericUpDown_FrameRight.Value, _Palette)); } }
public CImageResult CombineAndConvert(CImageFile[] files2combine) { CImageResult result = new CImageResult(new Bitmap(1, 1), -1, SHP_TS_EncodingFormat.Undefined, SHP_TS_BitFlags.None, Color.FromArgb(0, 0, 0), ""); if (files2combine.Length > 0) { CImageFile basefile = files2combine[0]; Bitmap convertedbaseimage = null; if (!basefile.IsSHP) { convertedbaseimage = LoadImageWithoutFuckingDPI(basefile.FileName, PaletteManager.GetPalette(basefile.PaletteIndex), basefile.CustomBackgroundColor, basefile.UseCustomBackgroundColor, basefile.CombineTransparentPixel); } else { convertedbaseimage = CSHaPer.GetFrame(basefile.FileName, basefile.SHPFrameNr, PaletteManager.GetPalette(basefile.PaletteIndex)); } //bool stores the Inverted transparency flag List <KeyValuePair <Bitmap, bool> > convertedsubimages = new List <KeyValuePair <Bitmap, bool> >(); if (files2combine.Length > 1) { for (int i = 1; i < files2combine.Length; i++) { if (!files2combine[i].IsSHP) { convertedsubimages.Add(new KeyValuePair <Bitmap, bool>( LoadImageWithoutFuckingDPI(files2combine[i].FileName, PaletteManager.GetPalette(files2combine[i].PaletteIndex), files2combine[i].CustomBackgroundColor, files2combine[i].UseCustomBackgroundColor, files2combine[i].CombineTransparentPixel), files2combine[i].CombineTransparentPixel)); } else { convertedsubimages.Add(new KeyValuePair <Bitmap, bool>( CSHaPer.GetFrame(files2combine[i].FileName, files2combine[i].SHPFrameNr, PaletteManager.GetPalette(files2combine[i].PaletteIndex)), false)); } } } Color avgRadarColor; //combine the palette indexed images convertedbaseimage = CombineImages(convertedbaseimage, convertedsubimages.ToArray(), basefile.RadarColorAverage, out avgRadarColor); result.bmp = convertedbaseimage; result.RadarColor = avgRadarColor; result.bitflags = basefile.BitFlags; return(result); } return(result);// new Bitmap(1, 1); }
private void ListFilesUsingColor() { enhmb = new EnhancedMessageBox(); enhmb.StartPosition = FormStartPosition.Manual; enhmb.Location = new Point(this.Location.X, this.Location.Y); enhmb.SetText("Processing files.\nThis may take a few seconds."); enhmb.SetCaption("Processing files."); enhmb.ProgressBarVisible(true); enhmb.button_OK_text("Abort"); enhmb.Show(); Cursor.Current = Cursors.WaitCursor; Application.DoEvents(); //finish showing the dialog before starting the cpu-intensive operation int filescount = this.listView_MainFileList.SelectedItems.Count; enhmb.ProgressBarSize(filescount); int pb = 0; foreach (ListViewItem item in this.listView_MainFileList.SelectedItems) { pb++; enhmb.SetText("Processing files.\nThis may take a few seconds.\n\nFile: " + item.Text); enhmb.ProgressBarValue((int)pb); Application.DoEvents(); //accept user input and when the messagebox is closed, stop working if (enhmb.Visible == false) { break; } item.Selected = CSHaPer.IsColorUsed(item.Tag.ToString(), (byte)this.uC_EditorPalette1.PaletteSelectedColor); }//foreach file enhmb.Close(); Application.DoEvents(); //finish showing the dialog before starting the cpu-intensive operation Cursor.Current = Cursors.Default; //create result file string result = ""; result = "Files using color result\r\n"; result += this.listView_MainFileList.SelectedItems.Count.ToString() + " Files found, using the color [" + this.uC_EditorPalette1.PaletteSelectedColor.ToString() + "]\r\n\r\n"; for (int i = 0; i < this.listView_MainFileList.SelectedItems.Count; i++) { result += this.listView_MainFileList.SelectedItems[i].Text + "\r\n"; } System.IO.File.WriteAllText(defaultPath + "#ColorUsage.txt", result); System.Diagnostics.Process.Start(defaultPath + "#ColorUsage.txt"); }
private void button_LoadSHP_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Load SHP"; ofd.InitialDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); if (!string.IsNullOrEmpty(InitialDirectory)) { ofd.InitialDirectory = this.InitialDirectory; } if (Cinimanager.inisettings.LastFireFLHFinderDirectory != "") { ofd.InitialDirectory = Cinimanager.inisettings.LastFireFLHFinderDirectory; } ofd.FileName = ""; ofd.Filter = "SHP(TS) files|*.shp"; ofd.Multiselect = true; if (ofd.ShowDialog() == DialogResult.OK) { if (!CSHaPer.IsSHP(ofd.FileName)) { MessageBox.Show("No valid SHP file!"); return; } SHPFile = ofd.FileName; Cinimanager.inisettings.LastFireFLHFinderDirectory = System.IO.Path.GetDirectoryName(ofd.FileName); CImageFile[] _SHPFrames = CSHaPer.GetFrames(ofd.FileName, 0); int oldleft = (int)this.numericUpDown_FrameLeft.Value; int oldright = (int)this.numericUpDown_FrameRight.Value; this.numericUpDown_FrameLeft.Value = 0; this.numericUpDown_FrameRight.Value = 0; this.numericUpDown_FrameLeft.Maximum = _SHPFrames.Length - 1; this.numericUpDown_FrameRight.Maximum = _SHPFrames.Length - 1; if (oldleft < this.numericUpDown_FrameLeft.Maximum) { this.numericUpDown_FrameLeft.Value = oldleft; } if (oldright < this.numericUpDown_FrameRight.Maximum) { this.numericUpDown_FrameRight.Value = oldright; } UpdateImages(); } }
private void AnalyzePaletteUsage(bool writeResultFile) { int filescount = this.listView_MainFileList.SelectedItems.Count; if (filescount > 1) { enhmb = new EnhancedMessageBox(); enhmb.StartPosition = FormStartPosition.Manual; enhmb.Location = new Point(this.Location.X, this.Location.Y); enhmb.SetText("Processing files.\nThis may take a few seconds."); enhmb.SetCaption("Processing files."); enhmb.ProgressBarVisible(true); enhmb.button_OK_text("Abort"); enhmb.Show(); Cursor.Current = Cursors.WaitCursor; Application.DoEvents(); //finish showing the dialog before starting the cpu-intensive operation enhmb.ProgressBarSize(filescount); } int pb = 0; paletteUsage = new long[256]; foreach (ListViewItem item in this.listView_MainFileList.SelectedItems) { pb++; if (filescount > 1) { enhmb.SetText("Processing files.\nThis may take a few seconds.\n\nFile: " + item.Text); enhmb.ProgressBarValue((int)pb); Application.DoEvents(); //accept user input and when the messagebox is closed, stop working if (enhmb.Visible == false) { break; } } int[] shpPaletteUsage = CSHaPer.GetSHPPaletteUsage(item.Tag.ToString()); for (int i = 0; i < shpPaletteUsage.Length; i++) { paletteUsage[i] += shpPaletteUsage[i]; } }//foreach file if (filescount > 1) { enhmb.Close(); Application.DoEvents(); //finish showing the dialog before starting the cpu-intensive operation Cursor.Current = Cursors.Default; } this.uC_EditorPalette1.PaletteUsage = paletteUsage; //create result file if (writeResultFile) { string result = ""; result = "Palette Usage Result\r\n"; result += "Colorindex = Number of pixel using that color\r\n\r\n"; for (int i = 0; i < paletteUsage.Length; i++) { result += string.Format("{0:000}", i) + " = " + paletteUsage[i].ToString() + "\r\n"; } System.IO.File.WriteAllText(defaultPath + "#PaletteUsage.txt", result); System.Diagnostics.Process.Start(defaultPath + "#PaletteUsage.txt"); } }