diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2015-02-17 17:36:06 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2015-05-02 21:36:45 +0200 |
commit | aa6c3e00a7f1ad8f2560ca18e17e278cddd9f0ca (patch) | |
tree | fb112710596f3951c4d799964ece3428f90bc17c | |
parent | 44e06d1777ae383603da4aec7d80844ca7391ff2 (diff) | |
download | pucket-aa6c3e00a7f1ad8f2560ca18e17e278cddd9f0ca.tar.gz pucket-aa6c3e00a7f1ad8f2560ca18e17e278cddd9f0ca.tar.bz2 pucket-aa6c3e00a7f1ad8f2560ca18e17e278cddd9f0ca.zip |
render: Add width/height command line options
-rw-r--r-- | main.c | 36 |
1 files changed, 33 insertions, 3 deletions
@@ -33,7 +33,7 @@ const char *argp_program_version = typedef struct { bool verbose; - unsigned int threads, bpc, quality, oversample; + unsigned int threads, bpc, quality, oversample, width, height; float scale; } render_arguments; @@ -51,6 +51,16 @@ static error_t parse_render_opt (int key, char *arg, break; } + case 'h': { + int i = atoi (arg); + if (i <= 0) { + argp_error (state, "Height must be > 0"); + } else { + arguments->height = i; + } + break; + } + case 'o': { int i = atoi (arg); if (i < 1) { @@ -74,19 +84,29 @@ static error_t parse_render_opt (int key, char *arg, case 's': arguments->scale = atof (arg); if (arguments->scale <= 0.0) { - argp_error (state, "Scale must be >= 0"); + argp_error (state, "Scale must be > 0"); } break; case 't': { int i = atoi (arg); if (i <= 0) { - argp_error (state, "Threads must be >= 0"); + argp_error (state, "Threads must be > 0"); } else { arguments->threads = i; } break; } + + case 'w': { + int i = atoi (arg); + if (i <= 0) { + argp_error (state, "Width must be > 0"); + } else { + arguments->width = i; + } + break; + } case ARGP_KEY_ARG: if (state->arg_num > 0) { @@ -123,6 +143,12 @@ static void do_render (const render_arguments * const arguments) { /* Force ntemporal_samples to 1 for -render */ genome->ntemporal_samples = 1; genome->sample_density = arguments->quality; + if (arguments->height != 0) { + genome->height = arguments->height; + } + if (arguments->width != 0) { + genome->width = arguments->width; + } genome->height *= arguments->scale; genome->width *= arguments->scale; genome->pixels_per_unit *= arguments->scale; @@ -416,6 +442,8 @@ int main (int argc, char **argv) { {"bpc", 'b', "8|16", 0, "Bits per channel of output image (8)" }, {"quality", 'q', "num", 0, "Average samples per pixel (100)" }, {"oversample", 'o', "num", 0, "Super-/Oversample image (1)" }, + {"width", 'w', "pixels", 0, "Output image width" }, + {"height", 'h', "pixels", 0, "Output image height" }, { 0 }, }; const char doc[] = "vlame3-render -- a fractal flame renderer"; @@ -431,6 +459,8 @@ int main (int argc, char **argv) { .quality = 100, .verbose = true, .oversample = 1, + .width = 0, + .height = 0, }; argp_parse (&argp, argc, argv, 0, NULL, &arguments); |