forked from tTh/FloatImg
rotate90 integrated in fimgfx
This commit is contained in:
parent
a600cbbf70
commit
14256b1476
2
.gitignore
vendored
2
.gitignore
vendored
@ -51,3 +51,5 @@ tools/addpnm2fimg
|
|||||||
tools/cumulfimgs
|
tools/cumulfimgs
|
||||||
tools/fimgops
|
tools/fimgops
|
||||||
tools/fimgfx
|
tools/fimgfx
|
||||||
|
tools/*.png
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* floatimg.h
|
* floatimg.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define FIMG_VERSION 96
|
#define FIMG_VERSION 97
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in memory descriptor
|
* in memory descriptor
|
||||||
|
@ -34,7 +34,7 @@ geometry.o: geometry.c $(DEPS)
|
|||||||
gcc $(COPT) -c $<
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
rotate.o: rotate.c $(DEPS)
|
rotate.o: rotate.c $(DEPS)
|
||||||
gcc $(COPT) -DDEBUG_LEVEL=1 -c $<
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
sfx0.o: sfx0.c $(DEPS)
|
sfx0.o: sfx0.c $(DEPS)
|
||||||
gcc $(COPT) -c $<
|
gcc $(COPT) -c $<
|
||||||
|
23
tools/essai.sh
Executable file
23
tools/essai.sh
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# essai des differents outils
|
||||||
|
#
|
||||||
|
|
||||||
|
# -----------------------------------------------------
|
||||||
|
|
||||||
|
TMPF="tmp.fimg"
|
||||||
|
|
||||||
|
# -----------------------------------------------------
|
||||||
|
function essai_rot90
|
||||||
|
{
|
||||||
|
echo "=== " $0 " ==="
|
||||||
|
./mkfimg -v -t hdeg $TMPF 800 600
|
||||||
|
./fimg2png -v $TMPF foo.png
|
||||||
|
./fimgfx -v rot90 $TMPF bar.fimg
|
||||||
|
}
|
||||||
|
# -----------------------------------------------------
|
||||||
|
|
||||||
|
essai_rot90
|
||||||
|
|
||||||
|
# -----------------------------------------------------
|
@ -17,24 +17,27 @@ typedef struct {
|
|||||||
char *name;
|
char *name;
|
||||||
int id;
|
int id;
|
||||||
int nbarg;
|
int nbarg;
|
||||||
|
int flags;
|
||||||
} Fx;
|
} Fx;
|
||||||
|
|
||||||
enum fxid { Fx_cos01=5, Fx_cos010, Fx_pow2, Fx_sqrt, Fx_gray0, Fx_halfsz0,
|
enum fxid { Fx_cos01=5, Fx_cos010, Fx_pow2, Fx_sqrt, Fx_gray0, Fx_halfsz0,
|
||||||
|
Fx_rot90,
|
||||||
Fx_xper };
|
Fx_xper };
|
||||||
|
|
||||||
Fx fx_list[] = {
|
Fx fx_list[] = {
|
||||||
{ "cos01", Fx_cos01, 0 },
|
{ "cos01", Fx_cos01, 0, 1 },
|
||||||
{ "cos010", Fx_cos010, 0 },
|
{ "cos010", Fx_cos010, 0, 1 },
|
||||||
{ "pow2", Fx_pow2, 0 },
|
{ "pow2", Fx_pow2, 0, 1 },
|
||||||
{ "sqrt", Fx_sqrt, 0 },
|
{ "sqrt", Fx_sqrt, 0, 1 },
|
||||||
{ "gray0", Fx_gray0, 0 },
|
{ "gray0", Fx_gray0, 0, 1 },
|
||||||
{ "halfsz0", Fx_halfsz0, 0 },
|
{ "halfsz0", Fx_halfsz0, 0, 1 },
|
||||||
{ "xper", Fx_xper, 0 },
|
{ "rot90", Fx_rot90, 0, 0 },
|
||||||
|
{ "xper", Fx_xper, 0, 1 },
|
||||||
{ NULL, 0, 0 }
|
{ NULL, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
int lookup_fx(char *txt)
|
int lookup_fxidx(char *txt)
|
||||||
{
|
{
|
||||||
Fx *fx;
|
Fx *fx;
|
||||||
int n;
|
int n;
|
||||||
@ -48,7 +51,7 @@ for (n=0, fx=fx_list; fx->name; fx++, n++) {
|
|||||||
fprintf(stderr, " -> %3d %s\n", n, fx->name);
|
fprintf(stderr, " -> %3d %s\n", n, fx->name);
|
||||||
#endif
|
#endif
|
||||||
if (!strcmp(fx->name, txt)) {
|
if (!strcmp(fx->name, txt)) {
|
||||||
return fx->id;
|
return n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1; /* NOT FOUND */
|
return -1; /* NOT FOUND */
|
||||||
@ -101,15 +104,15 @@ fimg_print_version(1);
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
int do_an_effect(char *sf, int act, char *df)
|
int do_an_effect(char *sf, int fxidx, char *df)
|
||||||
{
|
{
|
||||||
FloatImg src, dest;
|
FloatImg src, dest;
|
||||||
int foo;
|
int foo, action;
|
||||||
double maxval;
|
double maxval;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %s ( '%s' %d '%s' )\n", __func__,
|
fprintf(stderr, ">>> %s ( '%s' %d '%s' )\n", __func__,
|
||||||
sf, act, df);
|
sf, action, df);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
foo = fimg_create_from_dump(sf, &src);
|
foo = fimg_create_from_dump(sf, &src);
|
||||||
@ -120,13 +123,21 @@ if (foo) {
|
|||||||
|
|
||||||
maxval = (double)fimg_get_maxvalue(&src);
|
maxval = (double)fimg_get_maxvalue(&src);
|
||||||
|
|
||||||
|
if (fx_list[fxidx].flags & 1) {
|
||||||
foo = fimg_clone(&src, &dest, 0);
|
foo = fimg_clone(&src, &dest, 0);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "err clone %p : %d\n", &src, foo);
|
fprintf(stderr, "err clone %p : %d\n", &src, foo);
|
||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* XXX */
|
||||||
|
memset(&dest, 0, sizeof(dest));
|
||||||
|
}
|
||||||
|
|
||||||
switch (act) {
|
action = fx_list[fxidx].id;
|
||||||
|
|
||||||
|
switch (action) {
|
||||||
case Fx_cos01:
|
case Fx_cos01:
|
||||||
fimg_cos_01(&src, &dest, maxval); break;
|
fimg_cos_01(&src, &dest, maxval); break;
|
||||||
case Fx_cos010:
|
case Fx_cos010:
|
||||||
@ -143,14 +154,16 @@ switch (act) {
|
|||||||
case Fx_xper:
|
case Fx_xper:
|
||||||
do_experiment(&src, &dest, maxval); break;
|
do_experiment(&src, &dest, maxval); break;
|
||||||
|
|
||||||
|
case Fx_rot90:
|
||||||
|
foo = fimg_rotate_90(&src, &dest, 0); break;
|
||||||
|
|
||||||
case Fx_halfsz0:
|
case Fx_halfsz0:
|
||||||
fprintf(stderr, "not implemented\n");
|
fprintf(stderr, "halfsize was not implemented\n");
|
||||||
return -3;
|
return -3;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s %s : %d is bad action\n",
|
fprintf(stderr, "%s %s : %d is bad action\n",
|
||||||
__FILE__, __func__, act);
|
__FILE__, __func__, action);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -193,7 +206,7 @@ if (3 > argc-optind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
operator = argv[optind];
|
operator = argv[optind];
|
||||||
action = lookup_fx(operator);
|
action = lookup_fxidx(operator);
|
||||||
if (action < 0) {
|
if (action < 0) {
|
||||||
fprintf(stderr, "garbage found in opcode field : %s\n", operator);
|
fprintf(stderr, "garbage found in opcode field : %s\n", operator);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user