forked from tTh/FloatImg
better better better image maker
This commit is contained in:
parent
a5d4e5cc98
commit
7afe2b1b63
@ -1,4 +1,5 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
@ -7,9 +8,27 @@
|
|||||||
int verbosity;
|
int verbosity;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
void help(int lj)
|
#define T_BLACK 0
|
||||||
|
#define T_DRAND48 1
|
||||||
|
#define T_RGB_0 2
|
||||||
|
static int get_type(char *name)
|
||||||
{
|
{
|
||||||
fimg_print_version(1);
|
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, name);
|
||||||
|
|
||||||
|
#define TEST(str) ( ! strcmp(name, str) )
|
||||||
|
if TEST("black") return T_BLACK;
|
||||||
|
if TEST("drand48") return T_DRAND48;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
static void help(int lj)
|
||||||
|
{
|
||||||
|
|
||||||
|
puts("Usage:\n\tmkfimg [options] quux.fimg width height\n");
|
||||||
|
|
||||||
|
if (verbosity) fimg_print_version(1);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@ -20,32 +39,45 @@ int foo, opt;
|
|||||||
int width, height;
|
int width, height;
|
||||||
char *fname;
|
char *fname;
|
||||||
float fvalue;
|
float fvalue;
|
||||||
|
int type = 0;
|
||||||
|
|
||||||
FloatImg fimg;
|
FloatImg fimg;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "ho:v")) != -1) {
|
while ((opt = getopt(argc, argv, "ht:v")) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
case 'h': help(0); break;
|
case 'h': help(0); break;
|
||||||
|
case 't': type = get_type(optarg); break;
|
||||||
case 'v': verbosity++; break;
|
case 'v': verbosity++; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (4 != argc) {
|
#if DEBUG_LEVEL
|
||||||
fimg_print_version(1);
|
fprintf(stderr, "argc %d optind %d\n", argc, optind);
|
||||||
fprintf(stderr, "Usage:\n\t%s quux.fimg width height\n", argv[0]);
|
for (foo=0; foo<argc; foo++)
|
||||||
|
fprintf(stderr, "%3d %s\n", foo, argv[foo]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (3 != argc-optind) {
|
||||||
|
fprintf(stderr, "%s need filename, width & height\n", argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fname = argv[optind];
|
fname = argv[optind];
|
||||||
width = atoi(argv[optind+1]); height = atoi(argv[optind+2]);
|
width = atoi(argv[optind+1]); height = atoi(argv[optind+2]);
|
||||||
fprintf(stderr, "making '%s' %d x %d\n", fname, width, height);
|
|
||||||
|
if (verbosity) fprintf(stderr, "making '%s' %d x %d\n", fname, width, height);
|
||||||
|
|
||||||
foo = fimg_create(&fimg, width, height, 3);
|
foo = fimg_create(&fimg, width, height, 3);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "create floatimg -> %d\n", foo);
|
fprintf(stderr, "create floatimg -> %d\n", foo);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fimg_clear(&fimg);
|
|
||||||
|
switch(type) {
|
||||||
|
default:
|
||||||
|
case T_BLACK: fimg_clear(&fimg); break;
|
||||||
|
case T_DRAND48: fimg_drand48(&fimg, 1.0); break;
|
||||||
|
}
|
||||||
|
|
||||||
foo = fimg_dump_to_file(&fimg, fname, 0);
|
foo = fimg_dump_to_file(&fimg, fname, 0);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
|
Loading…
Reference in New Issue
Block a user