less bug, and a new effect

This commit is contained in:
tth 2021-04-20 12:06:19 +02:00
parent 1f03709b6c
commit 4872ec698c
1 changed files with 20 additions and 4 deletions

View File

@ -22,7 +22,7 @@ typedef struct {
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_cmixa, Fx_desat, Fx_ctr2x2, Fx_norm, Fx_rot90, Fx_cmixa, Fx_desat, Fx_ctr2x2, Fx_norm,
Fx_xper, Fx_binarize, Fx_hilight_R }; Fx_xper, Fx_binarize, Fx_trinarize,Fx_hilight_R };
Fx fx_list[] = { Fx fx_list[] = {
{ "cos01", Fx_cos01, 0, 1 }, { "cos01", Fx_cos01, 0, 1 },
@ -37,7 +37,8 @@ Fx fx_list[] = {
{ "desat", Fx_desat, 0, 1 }, { "desat", Fx_desat, 0, 1 },
{ "ctr2x2", Fx_ctr2x2, 0, 1 }, { "ctr2x2", Fx_ctr2x2, 0, 1 },
{ "norm", Fx_norm, 0, 1 }, { "norm", Fx_norm, 0, 1 },
{ "binarize", Fx_binarize, 0, 0 }, { "binarize", Fx_binarize, 0, 1 },
{ "trinarize", Fx_trinarize, 0, 1 },
{ "hilightr", Fx_hilight_R, 0, 1 }, { "hilightr", Fx_hilight_R, 0, 1 },
{ NULL, 0, 0, 0 } { NULL, 0, 0, 0 }
}; };
@ -94,6 +95,7 @@ return 0;
static void help(int lvl) static void help(int lvl)
{ {
Fx *fx; Fx *fx;
int foo;
printf("-- fimg special effects -- %s %s --\n", __DATE__, __TIME__); printf("-- fimg special effects -- %s %s --\n", __DATE__, __TIME__);
puts("usage:"); puts("usage:");
@ -105,8 +107,13 @@ puts("\t-v\tincrease verbosity");
puts("effects:"); puts("effects:");
printf("\t"); printf("\t");
foo = 0;
for (fx=fx_list; fx->name; fx++) { for (fx=fx_list; fx->name; fx++) {
printf("%s ", fx->name); foo += printf("%s ", fx->name);
if (foo > 55) {
printf("\n\t");
foo = 0;
}
} }
puts(""); puts("");
fimg_print_version(1); fimg_print_version(1);
@ -140,7 +147,7 @@ if (fx_list[fxidx].flags & 1) {
} }
} }
else { else {
/* XXX */ fprintf(stderr, "%s: ???\n", __func__); /* XXX */
memset(&dest, 0, sizeof(dest)); memset(&dest, 0, sizeof(dest));
} }
@ -187,6 +194,10 @@ switch (action) {
fimg_copy_data(&src, &dest); fimg_copy_data(&src, &dest);
foo = fimg_binarize(&dest, 0); foo = fimg_binarize(&dest, 0);
break; break;
case Fx_trinarize:
fimg_copy_data(&src, &dest);
foo = fimg_trinarize(&dest, 0);
break;
case Fx_hilight_R: case Fx_hilight_R:
foo = fimg_highlight_color(&src, &dest, 'R', 1.333); foo = fimg_highlight_color(&src, &dest, 'R', 1.333);
break; break;
@ -203,6 +214,11 @@ if (foo) {
return foo; return foo;
} }
fimg_destroy(&src);
if (dest.type) {
fimg_destroy(&dest);
}
return 0; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */