[brlcad-commits] SF.net SVN: brlcad:[65046] brlcad/trunk
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <car...@us...> - 2015-05-26 19:58:23
|
Revision: 65046 http://sourceforge.net/p/brlcad/code/65046 Author: carlmoore Date: 2015-05-26 19:58:20 +0000 (Tue, 26 May 2015) Log Message: ----------- implement s,w,n for gencolor Modified Paths: -------------- brlcad/trunk/doc/docbook/system/man1/en/gencolor.xml brlcad/trunk/src/util/gencolor.c Modified: brlcad/trunk/doc/docbook/system/man1/en/gencolor.xml =================================================================== --- brlcad/trunk/doc/docbook/system/man1/en/gencolor.xml 2015-05-26 19:29:11 UTC (rev 65045) +++ brlcad/trunk/doc/docbook/system/man1/en/gencolor.xml 2015-05-26 19:58:20 UTC (rev 65046) @@ -19,6 +19,9 @@ <command>gencolor</command> <arg choice='opt'>-r<replaceable>#</replaceable></arg> <arg choice='opt'>-p -b -L -H</arg> + <arg choice="opt" rep="norepeat">-{sS} <replaceable>squaresize</replaceable></arg> + <arg choice="opt" rep="norepeat">-{wW} <replaceable>width</replaceable></arg> + <arg choice="opt" rep="norepeat">-{nN} <replaceable>height</replaceable></arg> <arg choice='opt'><arg choice='plain' rep='repeat'><replaceable>val1 </replaceable></arg><arg choice='plain'><replaceable>valN</replaceable></arg></arg> </cmdsynopsis> </refsynopsisdiv> @@ -31,18 +34,20 @@ line, or in binary from its standard input (if not supplied, a single value of 0, for black, is assumed). The <option>-r</option> -flag can be used to specify the number of times to repeat the given -pattern, the default being infinity (unless any of <option>-p</option>, -<option>-b</option>, <option>-L</option>, and <option>-H</option> are used -- see below). +flag can be used to specify the number of times to repeat the given pattern, +the default being infinity (unless any other "-" options are used -- see below). This program is useful for producing a given grey value or color. Note that <command>gencolor</command> will refuse to write its output to a window; you must redirect the output to a file.</para> <para><option>-p</option> and <option>-b</option> are used to specify <replaceable>pix</replaceable> file and <replaceable>bw</replaceable> file, respectively. <option>-L</option> and <option>-H</option> are -used to specify low resolution and high resolution, respectively. By default, a pix file of low resolution -would be assumed; however, use of <option>-r</option> overrules any use of <option>-p</option>, -<option>-b</option>, <option>-L</option>, and <option>-H</option>.</para> +used to specify low resolution (squaresize 512) and high resolution (squaresize 1024), respectively. +<option>-w</option> (or <option>-W</option>) indicates the width; +<option>-n</option> (or <option>-N</option>) indicates the height; +width and height are set to the same value using <option>-s</option> (or <option>-S</option>). +By default, a pix file of low resolution is assumed; however, use of <option>-r</option> +overrules use of any other "-" options.</para> </refsect1> <refsect1 xml:id='example'><title>EXAMPLE</title> Modified: brlcad/trunk/src/util/gencolor.c =================================================================== --- brlcad/trunk/src/util/gencolor.c 2015-05-26 19:29:11 UTC (rev 65045) +++ brlcad/trunk/src/util/gencolor.c 2015-05-26 19:58:20 UTC (rev 65046) @@ -37,17 +37,16 @@ #define MAX_BYTES (128*1024) -static const char Usage[] = "Usage: gencolor [-r#] [val1 .. valN] > output_file\n"; +static const char Usage[] = +"Usage: gencolor [-r#] [-p -b -L -H]\n\ + [-s|S squaresize] [-w|W width] [-n|N height]\n\ + [val1 .. valN] > output_file\n"; int32_t count = -1; -int outputtype = 0; /* 1 for pix, 2 for bw; - * if this is used and resolution is not yet set, - * give resolution a default value of 1 - */ -int resolution = 0; /* 1 for low-res, 2 for hi-res; - * if this is used and outputtype is not yet set, - * give outputtype a default value of 1 - */ +int outputtype = 1; /* 1 for pix, 2 for bw */ +int width = 512; +int height = 512; +int typeselected = 0 ; /* set to 1 if any option other than -r appears */ int setrcount = 0; /* set to 1 if -r is detected */ unsigned char buf[MAX_BYTES]; @@ -56,8 +55,9 @@ printusage(int i) { bu_log("%s\n", Usage); - bu_log(" (Must redirect output; cannot send to tty)\n"); + bu_log(" (Must redirect output; cannot send to tty)\n"); if (i != 3) bu_exit(i, NULL); + fprintf(stderr, " Program continues running:\n"); } void @@ -66,7 +66,7 @@ int c; bu_optind = 1; - while ((c = bu_getopt(argc, argv, "r:pbLHh?")) != -1) { + while ((c = bu_getopt(argc, argv, "r:pbLHs:S:n:N:w:W:h?")) != -1) { switch (c) { case 'r': count = atoi(bu_optarg); @@ -76,30 +76,42 @@ break; case 'p': outputtype = 1; - if (resolution == 0) resolution = 1; + typeselected = 1; break; case 'b': outputtype = 2; - if (resolution == 0) resolution = 1; + typeselected = 1; break; case 'L': - resolution = 1; - if (outputtype == 0) outputtype = 1; + height = width = 512; + typeselected = 1; break; case 'H': - resolution = 2; - if (outputtype == 0) outputtype = 1; + height = width = 1024; + typeselected = 1; break; + case 's': + case 'S': + height = width = atoi(bu_optarg); + typeselected = 1; + break; + case 'n': + case 'N': + height = atoi(bu_optarg); + typeselected = 1; + break; + case 'w': + case 'W': + width = atoi(bu_optarg); + typeselected = 1; + break; default: /* 'h' '?' */ printusage(0); } } - if( isatty(fileno(stdout))) printusage(1); - if (argc == 1 ){ - printusage(3); - fprintf(stderr, " Program continues running:\n"); - } + if (isatty(fileno(stdout))) printusage(1); + if (argc == 1 ) printusage(3); return; } @@ -109,7 +121,6 @@ { int i, len, times, bytes_in_buf, copies_per_buf; int remainder = 0; - int32_t basemultiple = 262144; /* This is 512 squared. */ unsigned char *bp; get_args(argc, argv); @@ -136,22 +147,13 @@ len = 1; } -/* If -r was used, ignore -p,-b,-L,-H in favor of what -r provided; if -r was - * not used AND outputtype was not set, we have no arguments (other than the - * color values), and we'd go to the infinite loop which IS documented. +/* If -r was used, ignore all other "-" options in favor of what -r provided; + * if there were no "-" options at all, we have no arguments (other than the + * color values), and we go to the infinite loop which IS documented. */ - if (!setrcount && outputtype != 0) { - if (outputtype == 1) { - if (resolution == 1) - count = basemultiple*3; - else - count = basemultiple*12; - } else { - if (resolution == 1) - count = basemultiple; - else - count = basemultiple*4; - } + if (!setrcount && typeselected) { + count = width * height; + if ( outputtype == 1 ) count = count * 3; remainder = count % len; count = count/len; /* e.g., len is 3 for RGB for a pix file */ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |