Commit ee24a079 authored by Mabu's avatar Mabu

oversampling is now configurable

parent f3318eb8
Pipeline #141114 passed with stages
in 7 minutes and 47 seconds
......@@ -5,4 +5,9 @@ AC_PROG_CC
AC_CHECK_LIB([m], [log])
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
AC_ARG_ENABLE([oversampling], AS_HELP_STRING([--enable-oversampling], [Enable over sampling]))
AS_IF([test "x$enable_oversampling" = "xyes"], [
AC_DEFINE(HAVE_ZOOM_FACTOR, 1, [Oversampling (warning, use 40x more memory)])
])
AC_OUTPUT
/* main.c */
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#include "params.h"
#include "functions.h"
#include "options.h"
#include "types.h"
#define DIE(what) perror(what); return EXIT_FAILURE;
#if HAVE_ZOOM_FACTOR
#define ZOOM_FACTOR 6
#endif
int main(int argc, char *argv[])
{
int ret = EXIT_SUCCESS;
/* structure to store parameters */
params_t opts = DEFAULT_PARAMS;
if (0 != OPT_parse(argc, argv, &opts))
{
ret = EXIT_FAILURE;
......@@ -30,26 +34,31 @@ int main(int argc, char *argv[])
float **data_small;
/* compute fractal size from image size */
side = opts.width;
if (side < opts.height)
if (side < opts.height)
{ side = opts.height; }
/* display parameters if verbose mode */
if (opts.verbose)
{ OPT_display(&opts); }
image = calloc(4 * opts.width * opts.height, sizeof *image);
for (i = 0; i < 3; ++i)
{
#if HAVE_ZOOM_FACTOR
data[i] = calloc(ZOOM_FACTOR*side *ZOOM_FACTOR*side, sizeof **data);
#else
data[i] = calloc(side *side, sizeof **data);
#endif
}
if (NULL == image)
{ DIE("malloc"); }
/* compute fractal parameters from command line */
flame_cfg = CFG_get_config(&opts);
/* generate the fractal */
#if HAVE_ZOOM_FACTOR
FLAME_generate(data, ZOOM_FACTOR*side, opts.nb_points, flame_cfg);
/* resize the image (antialiasing) */
......@@ -57,14 +66,20 @@ int main(int argc, char *argv[])
/* make the fractal drawable */
FLAME_render(image, data_small, opts.width, opts.height, side);
#else
FLAME_generate(data, side, opts.nb_points, flame_cfg);
/* make the fractal drawable */
FLAME_render(image, data, opts.width, opts.height, side);
#endif
/* write the image */
BMP_write(opts.filename, image, 32, opts.width, opts.height);
/* clean up memory */
free(image);
}
}
/* free memory used by options (copied filenames) */
OPT_free(&opts);
return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment