From 4872ec698c6cb4f12b58062139b911223c941112 Mon Sep 17 00:00:00 2001 From: tth Date: Tue, 20 Apr 2021 12:06:19 +0200 Subject: [PATCH] less bug, and a new effect --- tools/fimgfx.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tools/fimgfx.c b/tools/fimgfx.c index b7bd9b3..71d6de5 100644 --- a/tools/fimgfx.c +++ b/tools/fimgfx.c @@ -22,7 +22,7 @@ typedef struct { 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_xper, Fx_binarize, Fx_hilight_R }; + Fx_xper, Fx_binarize, Fx_trinarize,Fx_hilight_R }; Fx fx_list[] = { { "cos01", Fx_cos01, 0, 1 }, @@ -37,7 +37,8 @@ Fx fx_list[] = { { "desat", Fx_desat, 0, 1 }, { "ctr2x2", Fx_ctr2x2, 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 }, { NULL, 0, 0, 0 } }; @@ -94,6 +95,7 @@ return 0; static void help(int lvl) { Fx *fx; +int foo; printf("-- fimg special effects -- %s %s --\n", __DATE__, __TIME__); puts("usage:"); @@ -105,8 +107,13 @@ puts("\t-v\tincrease verbosity"); puts("effects:"); printf("\t"); +foo = 0; 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(""); fimg_print_version(1); @@ -140,7 +147,7 @@ if (fx_list[fxidx].flags & 1) { } } else { - /* XXX */ + fprintf(stderr, "%s: ???\n", __func__); /* XXX */ memset(&dest, 0, sizeof(dest)); } @@ -187,6 +194,10 @@ switch (action) { fimg_copy_data(&src, &dest); foo = fimg_binarize(&dest, 0); break; + case Fx_trinarize: + fimg_copy_data(&src, &dest); + foo = fimg_trinarize(&dest, 0); + break; case Fx_hilight_R: foo = fimg_highlight_color(&src, &dest, 'R', 1.333); break; @@ -203,6 +214,11 @@ if (foo) { return foo; } +fimg_destroy(&src); +if (dest.type) { + fimg_destroy(&dest); + } + return 0; } /* --------------------------------------------------------------------- */