2021-04-08 05:55:38 +11:00
|
|
|
/*
|
|
|
|
* another ugly experiment
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2021-04-11 08:04:18 +11:00
|
|
|
#include <unistd.h>
|
2021-05-25 21:01:56 +11:00
|
|
|
#include <stdint.h>
|
2021-04-08 05:55:38 +11:00
|
|
|
|
|
|
|
#include "../floatimg.h"
|
|
|
|
|
|
|
|
int verbosity;
|
|
|
|
|
|
|
|
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
|
|
|
|
2021-04-11 08:04:18 +11:00
|
|
|
void help(int k)
|
|
|
|
{
|
|
|
|
puts("Usage:\n\textracteur in.fimg w,h,x,y out.???");
|
2023-07-07 21:27:48 +11:00
|
|
|
exit(k);
|
2021-04-11 08:04:18 +11:00
|
|
|
}
|
|
|
|
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
2021-04-08 05:55:38 +11:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2021-04-11 08:04:18 +11:00
|
|
|
int foo, opt;
|
2021-04-08 05:55:38 +11:00
|
|
|
FloatImg src, dst;
|
2021-04-28 09:21:45 +11:00
|
|
|
FimgArea51 zone;
|
2021-04-08 05:55:38 +11:00
|
|
|
char *infile = "foo.fimg";
|
|
|
|
char *outfile = "out.fimg";
|
|
|
|
|
2021-04-08 06:25:15 +11:00
|
|
|
verbosity = 0;
|
2021-04-08 05:55:38 +11:00
|
|
|
|
2023-07-07 21:27:48 +11:00
|
|
|
fprintf(stderr, "*** Extracteur (build: %s %s)\n", __DATE__, __TIME__);
|
2021-10-16 08:21:02 +11:00
|
|
|
|
2021-04-11 08:04:18 +11:00
|
|
|
while ((opt = getopt(argc, argv, "hv")) != -1) {
|
|
|
|
switch(opt) {
|
2023-07-07 21:27:48 +11:00
|
|
|
case 'h': help(0); break;
|
2021-05-10 10:15:29 +11:00
|
|
|
case 'v': verbosity++; break;
|
|
|
|
default: break;
|
2021-04-11 08:04:18 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (3 != argc-optind) {
|
2023-07-07 21:27:48 +11:00
|
|
|
fprintf(stderr, "---- %s ----\n", argv[0]);
|
2021-04-11 08:04:18 +11:00
|
|
|
help(1);
|
2021-04-08 05:55:38 +11:00
|
|
|
}
|
|
|
|
|
2021-04-16 21:34:45 +11:00
|
|
|
if (verbosity) {
|
|
|
|
fimg_print_version(1);
|
|
|
|
}
|
2021-04-08 05:55:38 +11:00
|
|
|
|
2021-04-11 08:04:18 +11:00
|
|
|
infile = argv[optind]; outfile = argv[optind+2];
|
2023-07-04 22:23:15 +11:00
|
|
|
fprintf(stderr, "%s\n\t%s --> %s\n", argv[0], infile, outfile);
|
2021-04-08 05:55:38 +11:00
|
|
|
|
|
|
|
foo = fimg_create_from_dump(infile, &src);
|
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "%s: err %d loading image '%s'\n", __func__,
|
|
|
|
foo, infile);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2021-04-11 08:04:18 +11:00
|
|
|
if (4 != parse_rectangle( argv[optind+1], &zone, 0) ) {
|
|
|
|
fprintf(stderr, "%s: error in parsing of '%s'\n",
|
|
|
|
argv[0], argv[optind+1]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// zone.w = src.width / 2; zone.h = src.height / 2;
|
|
|
|
// zone.x = src.width / 4 ; zone.y = src.height / 4;
|
|
|
|
|
2021-05-10 10:15:29 +11:00
|
|
|
if (verbosity) print_rectangle(argv[0], &zone);
|
2021-04-08 05:55:38 +11:00
|
|
|
|
|
|
|
foo = fimg_create(&dst, zone.w, zone.h, FIMG_TYPE_RGB);
|
2021-05-10 10:15:29 +11:00
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "NO PICZ EPIC FAIL %d\n", foo);
|
|
|
|
exit(1);
|
|
|
|
}
|
2021-04-08 05:55:38 +11:00
|
|
|
|
2021-04-25 21:51:01 +11:00
|
|
|
foo = fimg_extractor(&src, &dst, &zone);
|
2021-04-08 05:55:38 +11:00
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "EXTRACTOR EPIC FAIL %d\n", foo);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
foo = fimg_export_picture(&dst, outfile, 0);
|
2021-04-11 08:04:18 +11:00
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "export '%s' -> err %d\n", outfile, foo);
|
|
|
|
exit(1);
|
|
|
|
}
|
2021-04-08 05:55:38 +11:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|