11
11
12
12
#include "mandelbrot.h"
13
13
14
- static const char * OUTPUTFILE = "pngelbrot.png" ;
15
14
static const size_t NUM_COLORS = 5 ;
16
15
static int rgb_colors [NUM_COLORS ][3 ] = {
17
16
{ 255 , 255 , 255 },
@@ -151,7 +150,7 @@ choose_color(size_t escape, size_t maximum_iterations)
151
150
}
152
151
153
152
static void
154
- mandelbrot_cairo (size_t width , size_t height , size_t iterations , complex double center , double range )
153
+ mandelbrot_cairo (const char * outputfile , size_t width , size_t height , size_t iterations , complex double center , double range )
155
154
{
156
155
cairo_surface_t * my_surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24 , width , height );
157
156
cairo_t * my_cairo = cairo_create (my_surface );
@@ -176,14 +175,14 @@ mandelbrot_cairo(size_t width, size_t height, size_t iterations, complex double
176
175
}
177
176
}
178
177
179
- cairo_surface_write_to_png (my_surface , OUTPUTFILE );
178
+ cairo_surface_write_to_png (my_surface , outputfile );
180
179
181
180
cairo_destroy (my_cairo );
182
181
cairo_surface_destroy (my_surface );
183
182
}
184
183
185
184
static void
186
- mandelbrot_gd (size_t width , size_t height , size_t iterations , complex double center , double range )
185
+ mandelbrot_gd (const char * outputfile , size_t width , size_t height , size_t iterations , complex double center , double range )
187
186
{
188
187
gdImagePtr im = gdImageCreate (width , height );
189
188
FILE * pngout ;
@@ -203,17 +202,17 @@ mandelbrot_gd(size_t width, size_t height, size_t iterations, complex double cen
203
202
}
204
203
}
205
204
206
- pngout = fopen (OUTPUTFILE , "wb" );
205
+ pngout = fopen (outputfile , "wb" );
207
206
gdImagePng (im , pngout );
208
207
209
208
fclose (pngout );
210
209
gdImageDestroy (im );
211
210
}
212
211
213
- void mandelbrot (const char * backend , size_t width , size_t height , size_t iterations , complex double center , double range )
212
+ void mandelbrot (const char * backend , const char * outputfile , size_t width , size_t height , size_t iterations , complex double center , double range )
214
213
{
215
214
if (0 == strcmp ("cairo" , backend ))
216
- mandelbrot_cairo (width , height , iterations , center , range );
215
+ mandelbrot_cairo (outputfile , width , height , iterations , center , range );
217
216
else
218
- mandelbrot_gd (width , height , iterations , center , range );
217
+ mandelbrot_gd (outputfile , width , height , iterations , center , range );
219
218
}
0 commit comments