move extractor to func/
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
extern int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/*
|
||||
* really crude function, need more work...
|
||||
@@ -102,4 +104,35 @@ for (y=0; y<hd; y++) {
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int fimg_extractor(FloatImg *in, FloatImg *out, Rectangle *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(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;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
|
||||
@@ -70,6 +70,26 @@ if (!strcasecmp(name, "exr")) return FILE_TYPE_EXR;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/*
|
||||
* /!\ return 4 on success
|
||||
*/
|
||||
int parse_rectangle(char *str, Rectangle *r, int notused)
|
||||
{
|
||||
int x, y, w, h, foo;
|
||||
|
||||
if (verbosity)
|
||||
fprintf(stderr, "parsing %s\n", str);
|
||||
|
||||
foo = sscanf(str, "%d,%d,%d,%d", &w, &h, &x, &y);
|
||||
if (4 == foo) {
|
||||
r->x = x, r->y = y, r->w = w, r->h = h;
|
||||
return 4;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
int format_from_extension(char *fname)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user