public static CharBitmap Import(Bitmap bitmap, ImporterGenericArgs args = null) { // create importer instance var importer = new ImporterGeneric(bitmap, args); // show a progress bar while thing is being worked on (and wait for close) importer.worker.RunWorkerAsync(); importer.progressBox.ShowDialog(); // hide the progress box and return the image return(importer.targetBitmap); }
public ImporterGeneric(Bitmap bitmap, ImporterGenericArgs args) { worker.WorkerReportsProgress = true; worker.DoWork += Worker_DoWork; worker.ProgressChanged += Worker_ProgressChanged; worker.RunWorkerCompleted += Worker_Completed; worker.WorkerSupportsCancellation = true; sourceBitmap = bitmap; targetBitmap = new CharBitmap(bitmap.Width, bitmap.Height); progressBox.Text = "Importing bitmap..."; progressBox.Value = 0; progressBox.FormClosing += ProgressBox_FormClosing; }