Rendering Mandelbrot images with C#

Like many other Computer Science undergraduate students I wrote1 a program that renders images of the Mandelbrot set. Although my implementation is quite simple (a resume with most important details is listed below) it is a good working example that maybe can help others who are struggling with rendering fractals, implementing multi-threading or programming in C# in general.

Mandelbrot

It’s quite amazing how this seemingly simple calculation can generate such complex images.

Details on my implementation (order is quite random)

  1. 7 build-in presets (at locations I really like).
  2. Maximum supported number of iterations 60,000 (default setting is 400).
  3. Anti-aliasing up to 6 times (resolution of 7,200×7,200 pixels on high-res displays).
  4. Image is divided in chunks for parallel computation (default chunk size is 10 so the image is then cut into 10 * 10 = 100 parts).
  5. A progress bar is updated which indicates the number of finished chunks.
  6. All calculations are performed by the CPU.
  7. The red, green and blue tones can be adjusted separately.
  8. A rendered image can be saved as PNG, Jpeg or BMP.
  9. Mouse drag and drop to move the rendered image.
  10. Double left click to zoom in and double right click to zoom out (zoomfactor is 2).
  11. Max level of zoom is somewhere near 5E-17.

At nearly every point there is room for improvement but I’ll leave that up to you :D. You can download the source code or the executable on Github.

1 Part of the course “Imperative Programming” at Utrecht University.

Posted in C#, Development, Math, Windows