FloatImg4PythonBinding/tools/mkfimg.c

57 lines
1.1 KiB
C
Raw Normal View History

2019-03-04 02:22:55 +11:00
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "../floatimg.h"
2019-07-16 09:19:59 +11:00
int verbosity;
2019-03-04 02:22:55 +11:00
/* --------------------------------------------------------------------- */
2019-07-16 09:19:59 +11:00
void help(int lj)
{
fimg_print_version(1);
2019-03-04 02:22:55 +11:00
2019-07-16 09:19:59 +11:00
exit(0);
}
/* --------------------------------------------------------------------- */
2019-03-04 02:22:55 +11:00
int main(int argc, char *argv[])
{
2019-07-16 09:19:59 +11:00
int foo, opt;
2019-03-04 02:22:55 +11:00
int width, height;
char *fname;
FloatImg fimg;
2019-07-16 09:19:59 +11:00
while ((opt = getopt(argc, argv, "ho:v")) != -1) {
switch(opt) {
case 'h': help(0); break;
case 'v': verbosity++; break;
}
}
2019-03-04 02:22:55 +11: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 09:19:59 +11:00
fname = argv[optind];
width = atoi(argv[optind+1]); height = atoi(argv[optind+2]);
2019-07-04 03:51:42 +11:00
fprintf(stderr, "making '%s' %d x %d\n", fname, width, height);
2019-03-04 02:22:55 +11: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 09:19:59 +11:00
fprintf(stderr, "dump fimg -> %d\n", foo);
2019-03-04 02:22:55 +11:00
exit(1);
}
return 0;
}
/* --------------------------------------------------------------------- */