private void picShadeImg_MouseMove(object sender, MouseEventArgs e) { if (ds == null) { return; } closestStroke = ds.getClosestStroke(e.X, e.Y, out distToClosestStroke); if (closestStroke != null) { picShadeImg.Invalidate(); } if (rendered) { rendered = false; picShadeImg.Invalidate(); } if (drawingStroke) { if (!CurStrokeContainsPt(e.X, e.Y) && (e.X >= 0 && e.Y >= 0 && e.X < ds.ImageWidth && e.Y < ds.ImageHeight)) { curStroke.Add(new int[] { e.X, e.Y }); } lblStatus.Text = "Picking [" + e.X.ToString() + ", " + e.Y.ToString() + "]"; picShadeImg.Invalidate(); } if (pickingColor && e.X >= 0 && e.Y >= 0 && e.X < ds.ImageWidth && e.Y < ds.ImageHeight) { frmpalette.picCurColor.BackColor = ((Bitmap)picShadeImg.Image).GetPixel(e.X, e.Y); } }
private void stepbystepRenderToolStripMenuItem_Click(object sender, EventArgs e) { swRender.Reset(); lblStatus.Text = "Start rendering at" + DateTime.Now.ToString(); Application.DoEvents(); //if (!bgWorker.IsBusy) bgWorker.RunWorkerAsync(); //bgWorker_DoWork(sender, new DoWorkEventArgs(0)); //else lblStatus.Text = "Already rendering"; swRender.Start(); //compute distance maps if necessary for (int j = 0; j < ds._strokes.Count; j++) { lblStatus.Text = "Stroke " + (1 + j).ToString() + " of " + ds._strokes.Count.ToString(); Application.DoEvents(); DynamicShadingCPU.ColorStroke cs = ds._strokes[j]; if (cs.DistanceMap == null) { cs.DistanceMap = DynamicShadingCPU.GetPixelDistances(cs.StrokeCoords, ds._edges, ds.ImageWidth, ds.ImageHeight, ds.MAXITER); } picShadeImg.Image = ds.ComposeImage(); picShadeImg.Invalidate(); } bmpComposed = ds.ComposeImage(); swRender.Stop(); rendered = true; picShadeImg.Image = bmpComposed; picShadeImg.Invalidate(); lblStatus.Text = "Done rendering " + swRender.Elapsed.ToString(); }