/// <summary>Colorizes the image on a background thread.</summary> private void bwColorize_DoWork(object sender, DoWorkEventArgs e) { // Create the colorizer instance. Any progress updates // will in turn update the progress through the BackgroundWorker. ImageManipulation colorizer = new ImageManipulation(); colorizer.ProgressChanged += delegate(object s, ProgressChangedEventArgs pcea) { bwColorize.ReportProgress(pcea.ProgressPercentage); }; // Create a clone of the original image, so that we can lock its bits // while still allowing the UI to refresh and resize appropriately using (Bitmap workImage = _originalImage.Clone( new Rectangle(0, 0, _originalImage.Width, _originalImage.Height), PixelFormat.Format24bppRgb)) { // Colorize the image and store the resulting Bitmap e.Result = colorizer.Colorize(workImage, _selectedPixels, _lastEpsilon, _paths, btnParallel.Checked); } }
/// <summary>Colorizes the image on a background thread.</summary> private void bwColorize_DoWork(object sender, DoWorkEventArgs e) { // Create the colorizer instance. Any progress updates // will in turn update the progress through the BackgroundWorker. ImageManipulation colorizer = new ImageManipulation(); colorizer.ProgressChanged += delegate(object s, ProgressChangedEventArgs pcea) { bwColorize.ReportProgress(pcea.ProgressPercentage); }; // Create a clone of the original image, so that we can lock its bits // while still allowing the UI to refresh and resize appropriately using(Bitmap workImage = _originalImage.Clone( new Rectangle(0, 0, _originalImage.Width, _originalImage.Height), PixelFormat.Format24bppRgb)) { // Colorize the image and store the resulting Bitmap e.Result = colorizer.Colorize(workImage, _selectedPixels, _lastEpsilon, _paths, btnParallel.Checked); } }