forked from tTh/FloatImg
big clean on extractor
This commit is contained in:
parent
488893f6a3
commit
54d9a9939d
@ -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)
|
void help(int k)
|
||||||
{
|
{
|
||||||
puts("Usage:\n\textracteur in.fimg w,h,x,y out.???");
|
puts("Usage:\n\textracteur in.fimg w,h,x,y out.???");
|
||||||
|
exit(k);
|
||||||
}
|
}
|
||||||
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
||||||
|
|
||||||
@ -60,31 +29,22 @@ char *outfile = "out.fimg";
|
|||||||
|
|
||||||
verbosity = 0;
|
verbosity = 0;
|
||||||
|
|
||||||
#if 0
|
fprintf(stderr, "*** Extracteur (build: %s %s)\n", __DATE__, __TIME__);
|
||||||
for (foo=0; foo<argc; foo++) {
|
|
||||||
fprintf(stderr, "%9d %s\n", foo, argv[foo]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fprintf(stderr, "*** Extracteur %s %s\n", __DATE__, __TIME__);
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "hv")) != -1) {
|
while ((opt = getopt(argc, argv, "hv")) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
case 'h': help(0), exit(0); break;
|
case 'h': help(0); break;
|
||||||
case 'v': verbosity++; break;
|
case 'v': verbosity++; break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (3 != argc-optind) {
|
if (3 != argc-optind) {
|
||||||
fprintf(stderr, "---- %s errcli c=%d %d ----\n", argv[0],
|
fprintf(stderr, "---- %s ----\n", argv[0]);
|
||||||
argc, argc-optind);
|
|
||||||
help(1);
|
help(1);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbosity) {
|
if (verbosity) {
|
||||||
fprintf(stderr, "*** %s\n\t%s %s\n", argv[0], __DATE__, __TIME__);
|
|
||||||
fimg_print_version(1);
|
fimg_print_version(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user