--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/render_local.c Fri Jun 06 18:35:46 2008 +0300
@@ -0,0 +1,43 @@
+#include <stdlib.h>
+#include <assert.h>
+
+#include "common.h"
+#include "render_internal.h"
+#include "render_local.h"
+#include "render_png.h"
+#include "mandelbrot.h"
+
+int render_local (struct render *render, double *duration) {
+ assert(render->mode == RENDER_PNG);
+
+ unsigned char *rowbuf = NULL;
+ struct render_png *png_ctx = NULL;
+
+ *duration = -1;
+
+ // alloc the memory buffer
+ if (!(rowbuf = malloc(render->img_w)))
+ ERROR("malloc");
+
+ // the render_png stuff
+ if (!(png_ctx = render_png_init(render)))
+ ERROR("render_png_init");
+
+ // set render_* to use it
+ if (render_local_mem(render, &rowbuf, (int(*)(void *arg, unsigned char *)) &render_png_row, png_ctx))
+ ERROR("render_local_mem");
+
+ // then we can actually render
+ if (duration ? render_mandelbrot_timed(render, duration) : render_mandelbrot(render))
+ ERROR("render_mandelbrot");
+
+ // success
+ return 0;
+
+error:
+ free(rowbuf);
+ free(png_ctx);
+
+ return -1;
+}
+