/// <summary> /// Create a Mandelbrot Set then show it to the user asynchronously. /// </summary> /// <param name="func">The function to invoke asynchronously which will return a bitmap /// of a Mandelbrot Set</param> public async void DrawImageAsync(Size bitmapSize, ImageInfo imageInfo) { Form.OnRenderStart(); CurrentBitmapSize = bitmapSize; /* * get the current time which will be used to calculate how long it took to create and * then output the MandelbrotSet */ long before = DateTimeOffset.Now.ToUnixTimeMilliseconds(); await Task.Run(() => { var bitmap = MandelbrotSetBitmap.Render(bitmapSize, imageInfo); if (bitmap != null) { Form.MandelbrotSet = bitmap; } }); long after = DateTimeOffset.Now.ToUnixTimeMilliseconds(); //output the time taken to draw a Mandelbrot Set Form.CalculationTime = after - before; Form.AxisWidth = imageInfo.AxisWidth; Form.AxisHeight = imageInfo.AxisHeight; Form.OnImageChange(imageInfo); Form.OnRenderFinish(); }
public void Export() { if (form.AreOptionsValid()) { string path = CreatePath(form.Folder, form.FileName); var bitmapSize = form.BitmapSize; var imageInfo = new ImageInfo( CalculateAxisLengths(form.Magnification), form.FocusPoint); MandelbrotSetBitmap.ExportImageAsync( path, bitmapSize, imageInfo, form.iExportImage); } }