private void GradientGenerator_DoWork(object sender, DoWorkEventArgs e) { GrayBitmap asyncImage = (GrayBitmap)e.Argument; try { if (asyncImage.Gradient.Bitmap == null) { // Don't step through this code with an Locals or Auto // window opened at all. VS will crash the background thread. timer.Start(); asyncImage.Gradient.GenerateGradientBitmap(new ProgressCallback(GradientGenerator.ReportProgress)); timer.Stop(); e.Result = asyncImage.Gradient; } } catch (Exception ex) { e.Result = ex; } finally { asyncImage.Bitmap.Dispose(); } }
/// <summary> /// Clones this object so it can be safely read from another thread. /// </summary> /// <remarks> /// The clone will point to the original gray image. /// </remarks> public virtual GradientBitmap Clone(GrayBitmap newClonedGrayImage) { GradientBitmap clone = new GradientBitmap(newClonedGrayImage); clone.maximumGradientValue = this.maximumGradientValue; if (this.bitmap != null) clone.bitmap = (Bitmap)this.bitmap.Clone(); return clone; }
/// <summary> /// Instantiates a <see cref="GradientBitmap"/> class. /// </summary> public GradientBitmap(GrayBitmap original) { if (original == null) { throw new ArgumentNullException("original"); } this.grayBitmap = original; Reset(); }
public GrayBitmap Clone() { GrayBitmap clone = new GrayBitmap(); if (bitmap != null) clone.bitmap = (Bitmap)bitmap.Clone(); if (gradient != null) clone.gradient = gradient.Clone(clone); clone.maximumGrayValue = maximumGrayValue; return clone; }
/// <summary> /// Clones this object so it can be safely read from another thread. /// </summary> /// <remarks> /// The clone will point to the original gray image. /// </remarks> public virtual GradientBitmap Clone(GrayBitmap newClonedGrayImage) { GradientBitmap clone = new GradientBitmap(newClonedGrayImage); clone.maximumGradientValue = this.maximumGradientValue; if (this.bitmap != null) { clone.bitmap = (Bitmap)this.bitmap.Clone(); } return(clone); }
private void FileLoader_DoWork(object sender, DoWorkEventArgs e) { FileLoadingParams fileLoadingParams = (FileLoadingParams)e.Argument; timer.Start(); GrayBitmap img = new GrayBitmap(); string segmentationPoints; using (Stream file = fileLoadingParams.FileStream) img.Load(file, out segmentationPoints, new ProgressCallback(FileLoader.ReportProgress)); timer.Stop(); e.Result = new FileLoadingResult(img, segmentationPoints); }
public GrayBitmap Clone() { GrayBitmap clone = new GrayBitmap(); if (bitmap != null) { clone.bitmap = (Bitmap)bitmap.Clone(); } if (gradient != null) { clone.gradient = gradient.Clone(clone); } clone.maximumGrayValue = maximumGrayValue; return(clone); }
private void FileLoader_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { FileLoadingResult result = (FileLoadingResult)e.Result; Status = null; lblLastOperationTime.Text = timer.Elapsed.ToString(); if (result.GrayImage != null) { image = result.GrayImage; tbSegmentPoints.Text = result.SegmentationPoints; // Display the image. boxImage.BackgroundImage = image.Bitmap; boxImage.Image = PrepareOverlay(); boxGradient.BackgroundImage = image.Gradient.Bitmap; boxGradient.Image = boxImage.Image; // Enable toolbar buttons //btnShowGradient.Enabled = true; btnSaveFile.Enabled = true; // Size the application window appropriately. Width += boxImage.BackgroundImage.Width - boxImage.Width; Height += boxImage.BackgroundImage.Height - boxImage.Height; // Start generating the gradient right away GenerateGradient(); tabControl1.SelectTab(tabImage); } else if (result.Exception != null) { if (MessageBox.Show(this, result.Exception.ToString(), "Error during image load.", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry) { GenerateGradient(); } } }
/// <summary> /// constructor for intelligent scissors. /// </summary> /// <param name="image">the image you are oging to segment. has methods for getting gradient information</param> /// <param name="overlay">an overlay on which you can draw stuff by setting pixels.</param> public DijkstraScissors(GrayBitmap image, Bitmap overlay) : base(image, overlay) { }
public DijkstraScissors(GrayBitmap image, Bitmap overlay) : base(image, overlay) { }
public SimpleScissors(GrayBitmap image, Bitmap overlay) : base(image, overlay) { }
/// <summary> /// constructor for SimpleScissors. /// </summary> /// <param name="image">the image you are going to segment including methods for getting gradients.</param> /// <param name="overlay">a bitmap on which you can draw stuff.</param> public SimpleScissors(GrayBitmap image, Bitmap overlay) : base(image, overlay) { }
public StraightScissors(GrayBitmap image, Bitmap overlay) : base(image, overlay) { }
public FileLoadingResult(GrayBitmap grayImage, string segmentationPoints) { this.GrayImage = grayImage; this.SegmentationPoints = segmentationPoints; this.Exception = null; }
public FileLoadingResult(Exception ex) { this.Exception = ex; this.SegmentationPoints = null; this.GrayImage = null; }
private void FileLoader_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { FileLoadingResult result = (FileLoadingResult)e.Result; Status = null; lblLastOperationTime.Text = timer.Elapsed.ToString(); if (result.GrayImage != null) { image = result.GrayImage; tbSegmentPoints.Text = result.SegmentationPoints; // Display the image. boxImage.BackgroundImage = image.Bitmap; boxImage.Image = PrepareOverlay(); boxGradient.BackgroundImage = image.Gradient.Bitmap; boxGradient.Image = boxImage.Image; // Enable toolbar buttons //btnShowGradient.Enabled = true; btnSaveFile.Enabled = true; // Size the application window appropriately. Width += boxImage.BackgroundImage.Width - boxImage.Width; Height += boxImage.BackgroundImage.Height - boxImage.Height; // Start generating the gradient right away GenerateGradient(); tabControl1.SelectTab(tabImage); } else if (result.Exception != null) { if (MessageBox.Show(this, result.Exception.ToString(), "Error during image load.", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry) GenerateGradient(); } }
protected Scissors(GrayBitmap image, Bitmap overlay) { Image = image; Overlay = overlay; }
/// <summary> /// Instantiates a <see cref="GradientBitmap"/> class. /// </summary> public GradientBitmap(GrayBitmap original) { if (original == null) throw new ArgumentNullException("original"); this.grayBitmap = original; Reset(); }