public Flip(SVG svg) { GL.PushMatrix(); if (svg._Flipped) { GL.Translate(svg._FlipX, 0, 0); GL.Scale(-1, 1, 1); GL.Translate(-svg._FlipX, 0, 0); } }
public void LoadFileText(string file_text, string file_name) { DateTime dt = DateTime.Now; if (this._SVG_Playback != null) { this._DeleteableSVGS.Add(this._SVG_Playback); } this._LiveDrawIndex = -1; this._SVG_Playback = new SVG(file_text, file_name); this._SVG_Playback.InitializeImageChain(L1_SIZE); this.glControl1.Invalidate(); Console.WriteLine("LOAD ELAPSED:" + (DateTime.Now - dt).TotalMilliseconds); this.timerDraw.Enabled = false; if (!this._SVG_Playback._ViewBox.Equals(new Rectangle(0, 0, 800, 800))) { MessageBox.Show("MainForm: Incorrect Size"); } }
public Neighbor(int picturebox_size, SortableData sd) { this.SuspendLayout(); this.InitializeComponent(); this._PictureBoxSize = new Size(picturebox_size, picturebox_size); // this.lGroup.Text = sd._GroupName; // this.lFileName.Text = sd._FileName; // this.lIndex.Text = sd._Data._Index.ToString(); this._Index = sd._Data._Index; this._Path = Path.Combine(sd._GroupName, sd._FileName); Bitmap bp = new Bitmap( picturebox_size, picturebox_size, System.Drawing.Imaging.PixelFormat.Format24bppRgb); var path = Path.Combine( Properties.Settings.Default.DatabaseLocation, this._Path); if (File.Exists(path)) { string text; lock (MainForm.FileSystemL) text = File.ReadAllText(path); this._SVG = new SVG(text, "Compare"); this._SVG.getImageForSize(ref bp, picturebox_size, 9999999, true); if (sd._Flipped) { this._SVG.setFlipped(this._Index); } } this.pictureBox1.Image = bp; this.pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage; }
private void timerNearest_Tick(object sender, EventArgs e) { SVG svg = null; RectangleF r; if (this.rbModeDraw.Checked) { this._SVG_Drawn.SetImageChain(); this._SVG_Drawn._SectScaled.RefreshImage(ref this.DrawTrailScaled_Final); this._SVG_Drawn._SectScaledFiltered.RefreshImage(ref this.DrawTrailScaledFiltered_Final); this.pDrawTrailScaled.Invalidate(); this.pDrawTrailScaledFiltered.Invalidate(); svg = this._SVG_Drawn; r = svg.getRectangle(); } else { svg = this._SVG_Playback; r = svg.getRectangle(this._LiveDrawIndex); } this.LoadData(); if (this._Data == null) { return; } if (this.bwSearch.IsBusy) { return; } if (svg == null) { return; } if (svg._SectScaledFiltered == null) { return; } var sect = svg._SectScaledFiltered; var im_size = sect.getPrefferedSize(); /// 0 is white, 1 is blackest. var current_norm = new float[im_size.Width * im_size.Height]; var current_flip = new float[im_size.Width * im_size.Height]; int current_black = 0; int dex = 0; for (int y = 0; y < im_size.Height; y++) { for (int x = 0; x < im_size.Width; x++) { current_norm[dex] = 1 - sect[y, x]; if (current_norm[dex] > 0.99f) { current_black++; } dex++; } } dex = 0; for (int y = 0; y < im_size.Height; y++) { for (int x = im_size.Width - 1; x >= 0; x--) { current_flip[dex] = 1 - sect[y, x]; dex++; } } if (current_black == 0) { return; // No Data } /// WILL RUN FROM THIS POINT ON this.timerNearest.Enabled = false; this.DeleteNeighbor(); string key = null; if (this.cbRestrictSearch.Checked) { key = this.rbModeDraw.Checked ? this.comboBoxSelection.SelectedItem as String : this.lGroup.Text; } if ((key != null) && this._Data.ContainsKey(key)) { var ls = new List <Tuple <String, Dictionary <String, RawData[]> > > [1]; ls[0] = new List <Tuple <String, Dictionary <String, RawData[]> > >(); ls[0].Add(new Tuple <String, Dictionary <String, RawData[]> >(key, this._Data[key])); this.bwSearch.RunWorkerAsync(new SearchArgs(ls, current_flip, current_norm, current_black, r)); } else { var ls = new List <Tuple <String, Dictionary <String, RawData[]> > > [processors]; for (int i = 0; i < ls.Length; i++) { ls[i] = new List <Tuple <String, Dictionary <String, RawData[]> > >(); } dex = 0; bool add = this.comboBoxSelection.Items.Count == 0; foreach (var kvp in this._Data) { if (add) { this.comboBoxSelection.Items.Add(kvp.Key); } ls[dex++ % ls.Length].Add(new Tuple <String, Dictionary <String, RawData[]> >(kvp.Key, kvp.Value)); } if (add) { this.updateComboEnabled(); } this.bwSearch.RunWorkerAsync(new SearchArgs(ls, current_flip, current_norm, current_black, r)); } }
public void ThreadPoolCallback(Object threadContext) { int threadIndex = (int)threadContext; for (int i = 0; i < this._Groups.Length; i++) { if (i % this._Processors != threadIndex) { continue; } var group = this._Groups[i]; String group_name = group.Replace(this._RootDir + Path.DirectorySeparatorChar, ""); #if !DEBUG try #endif { DateTime dt = DateTime.Now; String new_path = Path.Combine(this._Dir, group_name); // if (String.Compare(group_name, "computer-mouse") < 0) continue; // Skip to if (File.Exists(new_path)) { File.Delete(new_path); } var ls = new List <object>(); foreach (var file in Directory.GetFiles(group)) { var svg = new SVG(File.ReadAllText(file), file); svg.InitializeImageChain(L1_SIZE); var ob = new Dictionary <string, object>(); ob["file_name"] = Path.GetFileName(file); foreach (var stuff in svg.SaveImageChain()) { ob[stuff._LiveDrawIndex.ToString()] = stuff._Pixels; } ls.Add(ob); } var json_array = ls.ToArray(); lock (MainForm.FileSystemL) { using (var fs = new StreamWriter(File.Create(new_path))) { JsonParser.print( json_array, fs.Write, fs.Write ); } } Console.WriteLine(group_name + ": " + (DateTime.Now - dt).TotalMilliseconds); } #if !DEBUG catch (Exception exc) { Console.WriteLine(group_name + ": " + exc.Message); } #endif } }