FloatImg/tools/mkfimg.c

59 lines
1.2 KiB
C
Raw Normal View History

2019-03-03 16:22:55 +01:00
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "../floatimg.h"
2019-07-16 00:19:59 +02:00
int verbosity;
2019-03-03 16:22:55 +01:00
/* --------------------------------------------------------------------- */
2019-07-16 00:19:59 +02:00
void help(int lj)
{
fimg_print_version(1);
2019-03-03 16:22:55 +01:00
2019-07-16 00:19:59 +02:00
exit(0);
}
/* --------------------------------------------------------------------- */
2019-03-03 16:22:55 +01:00
int main(int argc, char *argv[])
{
2019-07-16 00:19:59 +02:00
int foo, opt;
2019-03-03 16:22:55 +01:00
int width, height;
char *fname;
float fvalue;
2019-03-03 16:22:55 +01:00
FloatImg fimg;
2019-07-16 00:19:59 +02:00
while ((opt = getopt(argc, argv, "ho:v")) != -1) {
switch(opt) {
case 'h': help(0); break;
case 'v': verbosity++; break;
}
}
2019-03-03 16:22:55 +01:00
if (4 != argc) {
fimg_print_version(1);
fprintf(stderr, "Usage:\n\t%s quux.fimg width height\n", argv[0]);
exit(1);
}
2019-07-16 00:19:59 +02:00
fname = argv[optind];
width = atoi(argv[optind+1]); height = atoi(argv[optind+2]);
2019-07-03 18:51:42 +02:00
fprintf(stderr, "making '%s' %d x %d\n", fname, width, height);
2019-03-03 16:22:55 +01:00
foo = fimg_create(&fimg, width, height, 3);
if (foo) {
fprintf(stderr, "create floatimg -> %d\n", foo);
exit(1);
}
fimg_clear(&fimg);
foo = fimg_dump_to_file(&fimg, fname, 0);
if (foo) {
2019-07-16 00:19:59 +02:00
fprintf(stderr, "dump fimg -> %d\n", foo);
2019-03-03 16:22:55 +01:00
exit(1);
}
return 0;
}
/* --------------------------------------------------------------------- */