forked from tTh/FloatImg
more operators :)
This commit is contained in:
parent
2c758a4a61
commit
090a771971
@ -295,10 +295,21 @@ usage : fimgstats [options] file.fimg
|
||||
Operations diverses sur ou entre des images.
|
||||
|
||||
\begin{verbatim}
|
||||
Usage:
|
||||
usage:
|
||||
fimgops [options] A.fimg B.fimg operator D.fimg
|
||||
operators:
|
||||
add 1
|
||||
sub 2
|
||||
mix 3
|
||||
mul 4
|
||||
options:
|
||||
-g convert output to gray
|
||||
-k N.N set float value
|
||||
-v increase verbosity
|
||||
\end{verbatim}
|
||||
|
||||
Pour l'operateur \texttt{mix}, le paramêtre flottant doit
|
||||
être fourni en utilisant l'option \texttt{-k}.
|
||||
|
||||
\subsection{fimg2png, fimg2pnm, fimg2tiff}
|
||||
\index{fimg2png}\label{fimg2png}
|
||||
|
@ -7,9 +7,14 @@
|
||||
|
||||
int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
float global_fvalue;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
#define OP_ADD 1
|
||||
#define OP_SUB 2
|
||||
#define OP_MIX 3
|
||||
#define OP_MUL 4
|
||||
typedef struct {
|
||||
int code;
|
||||
@ -19,6 +24,7 @@ typedef struct {
|
||||
Opcode opcodes[] = {
|
||||
{ OP_ADD, "add" },
|
||||
{ OP_SUB, "sub" },
|
||||
{ OP_MIX, "mix" },
|
||||
{ OP_MUL, "mul" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
@ -27,7 +33,7 @@ static void pr_opcodes(void)
|
||||
Opcode *optr;
|
||||
puts("operators:");
|
||||
for (optr = opcodes; optr->code; optr++) {
|
||||
printf("\t%-20s %d\n", optr->op, optr->code);
|
||||
printf("\t%-15s %d\n", optr->op, optr->code);
|
||||
}
|
||||
}
|
||||
static int look_opcode(char *txt)
|
||||
@ -52,6 +58,10 @@ static void help(int lj)
|
||||
|
||||
puts("usage:\n\tfimgops [options] A.fimg B.fimg operator D.fimg");
|
||||
pr_opcodes();
|
||||
puts("options:");
|
||||
puts("\t-g convert output to gray");
|
||||
puts("\t-k N.N set float value");
|
||||
puts("\t-v increase verbosity");
|
||||
if (verbosity) fimg_print_version(1);
|
||||
exit(0);
|
||||
}
|
||||
@ -66,6 +76,11 @@ switch (action) {
|
||||
foo = fimg_add(A, B, D); break;
|
||||
case OP_SUB:
|
||||
foo = fimg_sub(A, B, D); break;
|
||||
case OP_MIX:
|
||||
if (verbosity) fprintf(stderr, "fvalue is %f\n",
|
||||
global_fvalue);
|
||||
foo = fimg_interpolate(A, B, D, global_fvalue);
|
||||
break;
|
||||
case OP_MUL:
|
||||
foo = fimg_add(A, B, D); break;
|
||||
default:
|
||||
@ -79,7 +94,6 @@ return foo;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foo, opt, action;
|
||||
float fvalue;
|
||||
char *operator;
|
||||
|
||||
FloatImg srcA, srcB, dest;
|
||||
@ -87,7 +101,7 @@ FloatImg srcA, srcB, dest;
|
||||
while ((opt = getopt(argc, argv, "hk:v")) != -1) {
|
||||
switch(opt) {
|
||||
case 'h': help(0); break;
|
||||
case 'k': fvalue = atof(optarg); break;
|
||||
case 'k': global_fvalue = atof(optarg); break;
|
||||
case 'v': verbosity++; break;
|
||||
}
|
||||
}
|
||||
@ -141,7 +155,8 @@ foo = fimg_create(&dest, srcA.width, srcA.height, srcA.type);
|
||||
|
||||
foo = exec_operator(&srcA, &srcB, action, &dest);
|
||||
if (foo) {
|
||||
fprintf(stderr, "operator exec give us a %d\n", foo);
|
||||
fprintf(stderr, "operator '%s' exec give us a %d\n",
|
||||
operator, foo);
|
||||
}
|
||||
|
||||
foo = fimg_dump_to_file(&dest, argv[optind+3], 0);
|
||||
|
Loading…
Reference in New Issue
Block a user