big clean on extractor

This commit is contained in:
tTh 2023-07-07 12:27:48 +02:00
parent 488893f6a3
commit 54d9a9939d
1 changed files with 4 additions and 44 deletions

View File

@ -12,41 +12,10 @@ int verbosity;
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
int essai_extraction(FloatImg *in, FloatImg *out, FimgArea51 *rect)
{
int foo;
int xs, ys, xd, yd;
int count;
float rgb[3];
if (verbosity) {
fimg_describe(in, "source");
fimg_describe(out, "destination");
print_rectangle((char *)__func__, rect);
}
count = 0;
for (yd=0; yd<rect->h; yd++) {
ys = yd + rect->y;
if ((ys<0) || (ys>=in->height)) continue;
for (xd=0; xd<rect->w; xd++) {
xs = xd + rect->x;
if ((xs<0) || (xs>=in->width)) continue;
fimg_get_rgb(in, xs, ys, rgb);
fimg_put_rgb(out, xd, yd, rgb);
count++;
}
}
// fprintf(stderr, "%s: %d pix moved\n", __func__, count);
return 0;
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
void help(int k)
{
puts("Usage:\n\textracteur in.fimg w,h,x,y out.???");
exit(k);
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
@ -60,31 +29,22 @@ char *outfile = "out.fimg";
verbosity = 0;
#if 0
for (foo=0; foo<argc; foo++) {
fprintf(stderr, "%9d %s\n", foo, argv[foo]);
}
#endif
fprintf(stderr, "*** Extracteur %s %s\n", __DATE__, __TIME__);
fprintf(stderr, "*** Extracteur (build: %s %s)\n", __DATE__, __TIME__);
while ((opt = getopt(argc, argv, "hv")) != -1) {
switch(opt) {
case 'h': help(0), exit(0); break;
case 'h': help(0); break;
case 'v': verbosity++; break;
default: break;
}
}
if (3 != argc-optind) {
fprintf(stderr, "---- %s errcli c=%d %d ----\n", argv[0],
argc, argc-optind);
fprintf(stderr, "---- %s ----\n", argv[0]);
help(1);
exit(1);
}
if (verbosity) {
fprintf(stderr, "*** %s\n\t%s %s\n", argv[0], __DATE__, __TIME__);
fimg_print_version(1);
}