public FastBitmap ProcessImage(FastBitmap bmp, BackgroundWorker worker) { DoPreprocessing(bmp); FastBitmap result = new FastBitmap(bmp.width, bmp.height); for (int y = 0; y < bmp.height; ++y) { worker.ReportProgress((int)(y * 100f / bmp.height)); if (worker.CancellationPending) { return(null); } for (int x = 0; x < bmp.width; ++x) { result.SetPixel(x, y, CalculateNewPixelColor(bmp, x, y)); } } return(result); }